Guess What

Heyyyy, it’s me again and this week, I’ve come with new things to share with you all!

Well, I would say that my performance this week was way better than last week. Just imagine, during the first week, when I used to look at the pile of codes and scroll through them, my head spins and I start seeing things in two, hahahahaha, okay I’m exaggerating, but honestly, it was so much to swallow and understand especially with the fact that this is my first time to literally get exposed to these things, everything is brand new to me.

Firstly, I tried to use input binding in resource dictionary but still couldn’t do it, because the problem was raising from the data context, the resource dictionary was not able to get access to the data context of the file which contains the definition of the commands. Then, I tried using the data context concept but still no success. So, I asked my supervisor to move on, yes I did told him that, because I was already losing interest in doing the same thing over and over again. So, I was asked to write a test for the Escape key, well I would say that I only managed to do 50% of the task, I also learnt the difference between Setup and Verify when using Moqs.

Before having a look at the difference between Setup and Verify, a simple definition that can be given to Moqs is that they are objects which mimic or copy the behavior of a class or an interface and allows methods in the test to interact with them as if they were real. Hence, Setups are usually associated with the fact that we set a method and invoke a return that we expect to be returned when the method has been set up or initiated. On the other hand, verify deals with the concept of ensuring that a certain method gets invoked when the requirements are fulfilled, such that we want to verify that when method A is invoked B should be returned, if B is not returned hence our test fails. Unfortunately, the test I wrote was only for checking whether the command gets executed or not, but not whether the escape key was pressed, because the definition of the key was written in the .xaml file not the .cs file.

Next, I was given a new task, in which I had to create a module for invoices which is related to a system being created. I’ve also updated my dictionary of definitions, so initially I had the idea that data context meant giving access to the data in other classes when in reality it means a network connection created among data points in files. I have also learnt that the .sample files extension in projects are not supposed to be deleted but to be kept and used for references.

Lastly, I have also created tests to test the data being saved into the database. Basically, the tests I wrote were to ensure that the data types assigned to each attribute is correct and is the data type required, meaning a test method is written to check whether the attribute name is assigned a string data type, if the name is not assigned to string then the test fails, because the actual and expected data types are not the same.

Basically, that’s a summary of all what I did, see you all again next week. Make sure you read my upcoming blog, which is surely to be filled with new things to learn 🙂

Implementation of Percentage and Tiny Integer

Adding in new button to new class that derive specific calculation. Value in new class consist of percentage, which then been used in calculation of existing ViewModel classes. This class would appear as data grid combo box in main WPF application.

While I am at it, I faced an issue where class name is similar in other module. I am unable to add in new data to correct database table. All the data I saved in current module appears in database table of existing module. After some tests, I found out that both module crosslinked. I manage to make it function properly refactor class name and region name of new module.

Then, I was required to implement new attribute “IsReady” with tinyint(1) in config. It is use to signal other module that It is ready to be used. In ViewModel, I implemented a dialog to ask whether user want selected data ready to be used; under same button, it undergoes same process to undo the changes made. Button text would change based value of attribute in database:

i – (Repo) If bool IsReady = true || 1 (value in database)
(VM) button text shows “Undo Ready to Use”

ii – (Repo) If bool IsReady= false || 0 (value in database)
(VM) button text shows “Ready to Use”

The button alter between (i) and (ii) whenever IsReady is successfully updated to the database.

Calculation in System and Malfunction of Buttons

Some calculation is needed in current system we are working on. Thus, I had to implement Regex for few text input. Allowing only numeric and special symbol to be used, restricts all alphabetic and any other symbol . With implementation of Regex, undefined result for calculation can be avoided.

Next, I need to allow calculation result to be 0 based on given example. Therefore, I added a check box within data grid of DetailView, hence, control my calculation result. Then, functionality is altered within DetailViewModel as we are maintaining MVVM implementation. As the check box is checked, it will set the result to 0; it will be actual result otherwise.

There is still some malfunction for state of my refresh button. Other buttons would become disable to be clicked after refresh button is triggered. I shall refactor my code to fix this issue, to ensure smooth user experience. Few unit tests is coded check if refresh button acts as intended.

Altering Tests based on Database Changes & Testing New Interface

I added new entity into existing database migration, and update stored value in database. Due to new entity is added, most unit tests and integration tests failed. When put those tests to debug, It appears that there is database type of exception. Hence, I need refactor existing Test Base by adding value for new entities in order for tests to assert properly.

After that, I get to play around with new interface and get familiar with it implementation. The implementation are the use of Regex, Unit of Measurement for calculation in system. Also, implementation of combo box, search bar, CRUD and data injection from few other MVVM services for functionality in system.

Get to Know About Prism Library for WPF

I acknowledged that Prism is great framework that support MVVM (Model View View Model) design pattern. First of all, I am introduced to few terms based on the course I followed on some courses and tutorials (Title : Introduction to Prism for WPF).

Next, I learnt how to perform view injection to allow certain text to be displayed when i run the the program. It is performed simply just by linking instance of region to specific region called as ” NAME” in XAML file. Other than that, I also followed some step to implement View Model Locator and construct property to allow connection between View(XAML file) and View Model(CS file) in prism.

Beside that, I came across to know about delegate command, where it is used to implement ICommand without require an event handler. Delegate command can invoke method defined in ViewModel and let u control the properties on view from ViewModel. Hence, I played around with ICommand provided by prism that bind UI gesture to particular action/event. Along side of that, I also try out composite command, where it is able to invoke multiple view on one touch and IEventAggregator, which is a good implementation when you have lots of objects that are potential event sources.

Lastly, I understood the purpose of Dialog in prism library as it is used to notify user of current system progress or asking for user’s confirmation upon an action. In dialog, it is divided into two type, where one is block interaction with the rest of the application (modal) and one is to allow user to still interact with the other part of application (non-modal).

Conclusion, I do have to admit spend quite some time understanding how prism library works as I am still weak in programming knowledge, but thanks to guidance from my supervisor and going through it several times, I managed to get a grab on my understanding.