Ejemplo n.º 1
0
        public void Query_NullPassed_ArgumentNullExceptionThrown()
        {
            // Arrange
            var sut = this.CreateSut(_factory);

            // Act
            var result = sut.Query(this.ConvertNullToQuery());

            // Assert
            EAssert.IsLeft(result);
            Assert.Equal(typeof(ArgumentNotSet), result.LeftContent().GetType());
        }
Ejemplo n.º 2
0
        public void Query_UnExpectedErrorOccurs_ErrorReturned()
        {
            // Arrange
            var sut = this.CreateSut(_factory);

            _connection.Close();

            // Act
            var result = sut.Query(this.ConvertWithPageAndSize(1, QueryConstants.MaxElements));

            // Assert
            EAssert.IsLeft(result);
            Assert.Equal(typeof(UnknownError), result.LeftContent().GetType());
        }
Ejemplo n.º 3
0
        public void Insert_UnexpectedErrorOccur_ErrorReturned()
        {
            // Arrange
            IEnumerable <TModel> data = this.SampleData.Take(2).ToList();

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

            IDatabaseCommandRepository <TId, TInput, TUpdate> repo = this.CreateSut(_factory);

            // Act
            var res = repo.Insert(this.ConvertToInvalidInput(newObj));

            // Assert
            EAssert.IsLeft(res);
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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());
        }
Ejemplo n.º 6
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.º 7
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());
        }