Ejemplo n.º 1
0
        public void Delete_DeleteAlreadyDeletedRecord_RecordIsNotDeletedFalseReturned()
        {
            // Arrange
            IEnumerable <TModel> data = this.SampleData.Take(1).ToList();

            this.InitializeStorage(_factory, 0);
            TModel newObj = data.ElementAt(0);

            IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory);
            var insertedRecordId = repo.Insert(this.ConvertToInput(newObj));

            repo.Delete(insertedRecordId.RightContent());

            // Act
            var result = repo.Delete(insertedRecordId.RightContent());

            // Assert
            EAssert.IsLeft(result);
            Assert.Equal(typeof(RecordNotFound), result.LeftContent().GetType());
        }
Ejemplo n.º 2
0
        public void Delete_InsertThenDelete_DeleteWasSuccessfulExecutedReturnedTrue(int initialCount)
        {
            // Arrange
            IEnumerable <TModel> data = this.SampleData.Take(initialCount + 1).ToList();

            this.InitializeStorage(_factory, initialCount);
            TModel newObj = data.ElementAt(initialCount);

            IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory);
            var insertedRecordId = repo.Insert(this.ConvertToInput(newObj));

            // Act
            var result = repo.Delete(insertedRecordId.RightContent());

            // Assert
            EAssert.IsRight(result);
            Assert.True(result.RightContent());
        }
Ejemplo n.º 3
0
        public void Delete_UnExpectedErrorOccurs_ErrorReturned()
        {
            // Arrange
            IEnumerable <TModel> data = this.SampleData.Take(2).ToList();

            this.InitializeStorage(_factory, 0);
            TModel insertObject = 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.Delete(insertedRecordId.RightContent());

            // Assert
            EAssert.IsLeft(result);
            Assert.Equal(typeof(UnknownError), result.LeftContent().GetType());
        }