Fix Overall Bug in Repository and View Model Class

First and foremost, I start the week by removing duplicate integrations tests. Then, fix failure tests on repository test class as all of it failed. It is fix by adding test_server config.xml file to map towards database. However, few tests on UOM (unit of measurement) failed. As the test class is testing actual database tests. Direct initialization is required to ensure function run throw the references, variable able to reach and store directed value.

Next, I have problem with state machine in the system. Upon deletion of selected data, the system would prompt error of state machine. State.DeleteTrigger() is not implemented to go to correct state next. Thus, the only way is to remove State.DeleteTrigger(). By removing State.DeleteTrigger(), the state machine would move from State.SelectedTrigger() to State.DeselectTrigger(), which is logical flow as mapped in State Machine class.

Repository class only handles database code which is CRUD command towards database. Thus, move business logic that wrongly implemented in repository class to Wrapper Service/View Model class. After moving those logic away from repository class, the code in repository is more tidy.

Last but not least, I find it weird that system does not prompt error under a concurrency situation when It suppose to. I ran through the system once and I found out problem occurs at my status checker from last week’s implementation. The value of _selectedStatus is set to SelectedStatus.Normal, which will constantly get latest data to update the list before I save any changes.

if (_selectedStatus == SelectedStatus.Normal)
{
_selectedStatus = SelectedStatus.Selected;
_eventAggregator.GetEvent().Publish(id); //Get Latest Data
}


Hence, database update is smooth as if there is no concurrency situation. But it will make user think they did not make any changes, if both before and after value appears to be the same. To solve this, I define _selectedStatus == SelectedStatus.Selected before I request to save changes upon editing selected data, so that it does not pass through get latest data event.

Leave a Reply