{"id":357,"date":"2021-07-13T14:37:47","date_gmt":"2021-07-13T06:37:47","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=357"},"modified":"2021-07-13T14:37:52","modified_gmt":"2021-07-13T06:37:52","slug":"first-month-in-tong-hin","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/","title":{"rendered":"First month in Tong Hin !"},"content":{"rendered":"\n<p>For this week , I have completed my first task (converting WPF to MVVM project) . I am finally able to move on to creating the unit tests for the completed task . For the unit tests , one of the important NuGet package used is Moq . Moq&nbsp;is a mocking framework for C#\/.NET.  It is used in unit testing to isolate your class under test from its dependencies and ensure that the proper methods on the dependent objects are being called.&nbsp;<\/p>\n\n\n\n<p>For Moq : Setup , Verify &amp; Callback is the most common command . The &#8220;Setup&#8221; command mocks a method and &#8220;Return&#8221; the specified value called . &#8220;Verify&#8221; marks the expectation of the mock and you can verify how many times it is called with Times.Once or Times.Never . A&nbsp;callback&nbsp;is a piece of code that is passed into to a method parameter to be executed from within that method. When using&nbsp;Moq&nbsp;to create test doubles, you can supply&nbsp;callback&nbsp;code that is executed when an expectation is met.<\/p>\n\n\n\n<p>Before completing the first task , codes have to be pushed into the branch. With lack of experience using git , I committed 4-5 of my commits into the wrong branch resulting in having to create a new feature in the branch . To fix this , my supervisor taught me how to cherry pick ( git cherry-pick [commit reference] ) , picking a commit from a branch and applying it to another to undo changes. <\/p>\n\n\n\n<p>Another scenario that happened this week is pushing the commit into the wrong branch . <strong><a href=\"https:\/\/dev.to\/moshe\/remove-accidentally-pushed-file-from-a-git-repository-history-in-4-simple-steps-18cg\">https:\/\/dev.to\/moshe\/remove-accidentally-pushed-file-from-a-git-repository-history-in-4-simple-steps-18cg<\/a><\/strong> (will link the solution provided by my supervisor here if mistakes happens again) . Reminder : check if in correct branch in git history before git push, git pull if in incorrect branch. <\/p>\n\n\n\n<p>Lastly , I learned about the ternary operator (which is a substitute for if..else statement used a lot in my academy back then) and is much shorter version . For example , <strong>Condition ? Expression1 : Expression2 <\/strong>; if the statement is true , the statement will return <strong>Expression1 <\/strong>and return <strong>Expression2 <\/strong>if false . It is called a ternary operator because the operator takes 3 operands . That is all for this week .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For this week , I have completed my first task (converting WPF to MVVM project) . I am finally able to move on to creating the unit tests for the completed task . For the unit tests , one of the important NuGet package used is Moq . Moq&nbsp;is a mocking framework for C#\/.NET. It &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;First month in Tong Hin !&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[4],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>First month in Tong Hin ! | Tong Hin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"First month in Tong Hin ! | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"For this week , I have completed my first task (converting WPF to MVVM project) . I am finally able to move on to creating the unit tests for the completed task . For the unit tests , one of the important NuGet package used is Moq . Moq&nbsp;is a mocking framework for C#\/.NET. It &hellip; Continue reading &quot;First month in Tong Hin !&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-13T06:37:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-13T06:37:52+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\",\"name\":\"First month in Tong Hin ! | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2021-07-13T06:37:47+00:00\",\"dateModified\":\"2021-07-13T06:37:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/\",\"name\":\"First month in Tong Hin !\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/edf00f798aa3304d5b1c2f40ca0bc301\"},\"headline\":\"First month in Tong Hin !\",\"datePublished\":\"2021-07-13T06:37:47+00:00\",\"dateModified\":\"2021-07-13T06:37:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"keywords\":\"git\",\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2021\/07\/13\/first-month-in-tong-hin\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/edf00f798aa3304d5b1c2f40ca0bc301\",\"name\":\"Wang Qi Le\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4f522ad020f37316008f6f8757e45090?s=96&d=mm&r=g\",\"caption\":\"Wang Qi Le\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/357"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":2,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"predecessor-version":[{"id":360,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/357\/revisions\/360"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}