public void Update1_ParameterCheck() { var repository = GetScenario(); EmployeeClassificationFlagsUpdater value = null !; Assert.ThrowsException <ArgumentNullException>(() => repository.UpdateWithObject(value)); }
public void PartialUpdate_OneScenarioTwoMessages() { var repositoryA = GetScenario(); //Setup the new record var newRecord = new TModel() { EmployeeClassificationName = "Test " + DateTime.Now.Ticks, IsExempt = true, IsEmployee = false }; var newKey = repositoryA.Create(newRecord); Assert.IsTrue(newKey >= 1000, "keys under 1000 were not generated by the database"); { //Get a copy of the record using repository A var versionA1 = repositoryA.GetByKey(newKey); Assert.IsNotNull(versionA1); Assert.AreEqual(newKey, versionA1 !.EmployeeClassificationKey); Assert.AreEqual(newRecord.EmployeeClassificationName, versionA1.EmployeeClassificationName); Assert.AreEqual(newRecord.IsExempt, versionA1.IsExempt); Assert.AreEqual(newRecord.IsEmployee, versionA1.IsEmployee); } //Create the updaters var updateMessage1 = new EmployeeClassificationFlagsUpdater() { EmployeeClassificationKey = newKey, IsExempt = false, IsEmployee = true }; var updateMessage2 = new EmployeeClassificationNameUpdater() { EmployeeClassificationKey = newKey, EmployeeClassificationName = "Updated " + DateTime.Now.Ticks }; repositoryA.UpdateWithObject(updateMessage1); repositoryA.UpdateWithObject(updateMessage2); { //get the final version using repository A var versionA2 = repositoryA.GetByKey(newKey); Assert.IsNotNull(versionA2); Assert.AreEqual(newKey, versionA2 !.EmployeeClassificationKey); Assert.AreEqual(updateMessage2.EmployeeClassificationName, versionA2.EmployeeClassificationName); Assert.AreEqual(updateMessage1.IsExempt, versionA2.IsExempt); Assert.AreEqual(updateMessage1.IsEmployee, versionA2.IsEmployee); } }