public void Update_UnExistingObjectUpdate_ErrorReturned() { // Arrange IEnumerable <TModel> data = this.SampleData.Take(4).ToList(); this.InitializeStorage(_factory, 0); TModel updateObject = data.ElementAt(3); IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory); // Act var result = repo.Update(this.GetUnExistingId(), this.ConvertToUpdate(updateObject)); // Assert EAssert.IsLeft(result); Assert.Equal(typeof(RecordNotFound), result.LeftContent().GetType()); }
public void Update_InvalidUpdateObject_ArgumentNotSetErrorReturned() { // Arrange IEnumerable <TModel> data = this.SampleData.Take(2).ToList(); this.InitializeStorage(_factory, 0); TModel insertObject = data.ElementAt(1); TModel updateObject = data.ElementAt(1); IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory); var insertedRecordId = repo.Insert(this.ConvertToInput(insertObject)); // Act var result = repo.Update(insertedRecordId.RightContent(), this.ConvertToInvalidUpdate(updateObject)); // Assert EAssert.IsLeft(result); Assert.Equal(typeof(ArgumentNotSet), result.LeftContent().GetType()); }
public void Update_ExistingObjectModified_UpdateDoneSuccessfullTrueReturned(int storageCount, int targetIndex) { // Arrange IEnumerable <TModel> data = this.SampleData.Take(storageCount + 1).ToList(); this.InitializeStorage(_factory, storageCount); TModel insertObject = data.ElementAt(storageCount); TModel updateObject = data.ElementAt(targetIndex + 1); IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory); var insertedRecordId = repo.Insert(this.ConvertToInput(insertObject)); // Act var result = repo.Update(insertedRecordId.RightContent(), this.ConvertToUpdate(updateObject)); // Assert EAssert.IsRight(result); Assert.True(result.RightContent()); }
public void Update_UnExpectedErrorOccurs_ErrorReturned() { // Arrange IEnumerable <TModel> data = this.SampleData.Take(2).ToList(); this.InitializeStorage(_factory, 0); TModel insertObject = data.ElementAt(1); TModel updateObject = data.ElementAt(1); IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory); var insertedRecordId = repo.Insert(this.ConvertToInput(insertObject)); // this should make update to throw unexpected error _connection.Close(); // Act var result = repo.Update(insertedRecordId.RightContent(), this.ConvertToUpdate(updateObject)); // Assert EAssert.IsLeft(result); Assert.Equal(typeof(UnknownError), result.LeftContent().GetType()); }