Brainstorming on new task

For the previous week, I had completed with the User module and merged with the master project. I’ve been assigned with new task which is develop the sales order picking module. I’ve been briefed on the module such as its functionalities, requirements, input data and output data that the module should produce.

After that, I’ve started to brainstorming toward the module. I’ve figured and listed down the business flow of the sales order picking module. First of all, user will need to select the sales order that they wish to pick. On the same time, the selected sales order details / attribute will also be shown in the same view. The line items that contained in the selected sales order. Therefore, user will able to proceed with their picking process by entering the amount to pick.

Lastly, I’ve designed the UI of the module and amend it based on the requirements and make it to be more user friendly. I’ve also started to design the Pick service which will contains all the service needed and will be used in the view model in the future.

Utilizing EF Core Exception Handling & Debugging CRUD methods

I continued my progress with fixing delete function, which suppose to remove linked data in multiple table across the database. The failure of delete function due to certain entity are set as foreign key of other table. This problem is solved by setting null value for related foreign key in delete function. As the value of foreign key is null, deletion is allowed as how it suppose to behave.

Next, I alter sequence of textbox in View class. To ensure best user experience when they uses hotkey “Tab” to navigates over to next textbox available.

Then, Remove validation made in ViewModel class and implement it in repository class. Allowing EF core throw error whenever unique entity is input multiple time. The error will be catch, hence, prompt dialog box to notify user of application. This way is a better implementation reduce number of code, however it cause few issue in application. Issue such as user unable to create new user after error popped up to indicate similar user id appears in database.

In conjunction, RepositoryActualDbTests class is created to mock my situation. I arrange declaration, execute three seperate input ( 1st input : id = 1, 2nd input : id = 1, 3rd input : id = 2 ) , and assert expected behaviour ( Total of 2 input should be saved input database ). After quite an amount of testing and struggling, the bug is then fixed, however it requires chain fix in code. Therefore, my supervisor advice me to try out a different implementation for my create function by mocking a test.

Validating and Granting Access Rights

For new context and module added last week, I imitate some tests from example code provided and add few new tests. I also create some class to build dummy database to ease unit/integration testing. After going through some tests, I found out error when deleting data. Upon deletion, only data from 1 table is deleted, delete function suppose to remove few linked data across the database.

Before I look through into bugs of deletion, I make new implementation to validate user input in required textbox. If textbox is empty for non-nullable textbox, I create validation for system to prompt warning dialog to notify user. such as below :
if (string.IsNullOrEmpty(Wrapper.Variable))
{
_dialogService.ShowDialog( n, p, r );
return false;
}


Besides, Admin role is added to alter availability of buttons in system. I was been told to make initialization of adminUser as variable. Variable adminUser is set to bool = false initially, and will be implement in feature implementation. If bool adminUser = true, user is an admin user; bool adminUser = false, user is normal user. The reason of adding in admin role is to restrict some functionality of normal user. For normal user, the system will hinder user from edit or delete data in the system. In significant, admin user will be granted privilege to edit and delete.

Implementation of FlaUI and Wrapper Class

For this week, I’ve started with the unit testing for the Hash Generator application. However, due to the Hash Generator is a Windows Form application , I’ve faced the problem when conducting the unit testing. It will pop out the message box while the test is running while I will need to close the dialog manually while running the unit tests.

In order to solve this problem, I had implemented the FlaUI which is a .net library which helps with automated UI testing of Windows applications. Not only that, I’ve also learned to implement the Thread.Sleep() and Retry.WhileException() which is used to retry the automation process if it fails to find descendants.

After that, I had implement the User and Privilege Wrapper class for the entire User Module in order to place the logged in user in the wrapper class for other module to verify the user’s privilege and authorize with relevance rights.

Implementation of New Context and Module

As I commits previous task, I now proceed to the next task and given duration of 3 weeks. I am required to create certain function of the application, which records details of customer. Thus, I begin my progress by developing UI View in XAML class based on given example. It is to ensure standardized UI across the application.

Next, based on given example, I implement Configuration, Repository class and perform Migration to database in context file; ViewModel, Event, and Parameter class in module file. Besides, I also perform tests for customerRepository and customerViewModel to makesure they work as expected.

There are some mistake that I did during these implementation, which caused failure of saving customer data into database. After going through some repository test, everything ran successful. Then, I found out that I failed to bind my View and ViewModel. After refactoring the codes, I manage to solve my problem.

Modifications on User Module

For this week, I’ve been assigned with new tasks that required to move the user creation features from user module to hash generator project and implement new features such as user edit, delete and editable custom salt in hash generator project.

Firstly, I’ve create the UI for the hash generator. I’ve also created a new model class and database table that used to store the editable custom salt. For the hash generator, it allows user to add and update a custom salt that will be used together with the hash generation. By updating the custom salt, it will reset all user password to default password.

After the hash generator project had finish implemented those features, I’ve started to remove the existing features from the user module. I’ve also create unit tests for the hash generator project.

Implementation Synchronous and Asynchronous Test in TDD

After learning about implementation of integration test, my next task will be testing out concurrency situation, where ID increment behaviour upon user deleting existing data and adding new data at the same time. Test is done by implementing two different task function. The flows of tasks is controlled by using semaphore implementation which is WaitAsync() and Release().

Initially, I implement the asynchronous test by separating add data and delete data into two task. Then I create new semaphore instances of semaLock1 and semaLock2. Hence, I control the tasks using semaphore, start the test by implementing task as user’s control. task Delete start, Meanwhile, task Add will begin and end first before task Delete end. The test was partially successful as I successfully increment the ID. However, I am unable to perform the asynchronous test as the delete function throws out multiple exception, despite I implement try catch blocks.

After a long time of struggle, I seek help from supervisor and we decide to make it simple, and perform the test synchronously. The test is much more simpler, but it is sufficient to proof the behaviour of function as planned.

I also did test of deleting existing data and adding new add after in asynchronous way. Which it only requires me to use same function from last test, to decrement current ID when latest data is deleted, and increment current ID when new data added.

Lastly, what I am able to observe during these tests, is that semaphore provides a good control to manage the flow of codes, but it might put user into infinite loops whenever semaphore is implement wrongly. For example, when there is only two semaLock in my test, semaLock1.WaitAsync() and semaLock2.WaitAsync() would make both task waits for each other.

Development of User Module

For the second week, I’ve continue with the development of user module that being assigned in last week. For last week’s progression, the user context had been developed and configured. Therefore, I’ve started to develop the UI for both login and registration view.

While the process of developing the view model for both views, I had face the problem on the PasswordBox UI element which blocks the binding from view model. After I referred the sample code and search for solutions, I’ve learnt and able to handle the parameter passing of PasswordBox elements to view model.

Not only that, I’ve also setup some unit tests for all view models that I’ve created. However, I was not able to use the [Fact] attribute for the unit tests since the unit tests will require UI element to run the unit test for the login and registration view model. Therefore, instead of [Fact] attribute, I’ve used the [StaFact] attribute which allowed the tests to run with the UI elements.

Lastly, I’ve being assigned with new task which is to develop a new view that allow user to modify their display name and password as well.

Integration Test in Development

As I continue with given project, I study about mapping of state machine, so that I am familiar with the sequence of state. As I am clear with the flow of state machine, I then perform few integration test by creating instances along with initialization of ViewModel class, Event class, mocking IDialogService and IRegionManager.

The first integration test start with New button, I ensure the button to do what I expecting it to do. On click, New button should load a view with blank form as I need to let user input new set of data, which then will be saved into the database. Next integration test is Edit button behaviour test, the button should be available as one existing sequence was selected. Edit button allow user to select existing set of data, thus, edit certain data and change should be saved. After testing Edit button, I move on to Delete button, which is tested to make sure existing data in database can be deleted according to logic function from repository class.

As I am performing tests, I learnt to use debugger upon refactoring codes. If there is error in codes during testing, I would breakpoint on line of code and run the debugger to find where is the problem located. Debugger save me a lot of time to identify where I could have done wrong. Beside debugger, sometimes I would also use logger to make sure I get the output I want during testing. I truly having hard time when I perform functionality test on my first button, but debugger and logger come in handy.

Other than integration test, I learnt about idea of semaphore where it is used to provide synchronization of tasks with signaling mechanism. Two operation used in semaphore is wait() and signal() operation. it allows more than one thread to access the crictical section, but does not allow multiple processes to enter. It allow flexible management of resources.

Introduction to Materials Needed for Development

In this week, I’ve go through the resources that required for the project before getting started with the development. For the first, I’ve learnt the usage of git repository by going through some tutorials. It’s used for tracking changes made on source code during development with multiple programmers. Not only that, I’ve also learnt on how to interact with the git repository by using Bitbucket and Sourcetree such as push and pull.

Furthermore, I’ve also get myself familiar with Test Driven Development (TDD) concept which is the development approach that emphasize on testing and refactoring the functions repeatedly. Instead of just getting familiar with the concepts, I’ve also try on its exercise files in order to learn on how to implement and apply the concepts into the project.

Moreover, I’ve learnt the Prism Library for WPF which is the framework that helps to create application that have loosely coupled components. In the course, I’ve learnt how to implement the features such as delegate command, custom dialogs, event aggregator and others as well.

Lastly, after I’ve went through these materials that required for the project, I had been given the task for developing the user module which is the login and create account page. I’ve started the development from creating the repository, set up the config for the model class and create the database that run by Docker which can connect to the database without it install locally.