Beispiel #1
0
        public void Constructor_Must_ThrowExceptions()
        {
            // Arrange
            var    fixture = new ListHandlerFixtures(ListHandlerFixtures.TestTypeEnum.Ok);
            Action sut1    = () => new ListHandlerFixtures.ListHandlerMock(
                null, fixture.Mapper.Object);
            Action sut2 = () => new ListHandlerFixtures.ListHandlerMock(
                fixture.ReadOnlyRepository.Object, null);

            // Act

            // Assert
            Assert.Throws <ArgumentNullException>(sut1);
            Assert.Throws <ArgumentNullException>(sut2);
        }
Beispiel #2
0
        public async void Handler_Must_ThrowException(ListHandlerFixtures.TestTypeEnum testType, Type typeException)
        {
            // Arrange
            var fixture = new ListHandlerFixtures(testType);
            var query   = fixture.Query;
            var sut     = new ListHandlerFixtures.ListHandlerMock(
                fixture.ReadOnlyRepository.Object,
                fixture.Mapper.Object);

            // Act
            Exception ex = await Assert.ThrowsAnyAsync <Exception>(async() => await sut.Handle(query, default));

            // Assert
            Assert.Equal(typeException, ex.GetType());
            fixture.ReadOnlyRepository.VerifyAll();
            fixture.ReadOnlyRepository.VerifyNoOtherCalls();
        }
Beispiel #3
0
        public async void Handler_MustReturn_Result()
        {
            // Arrange
            var fixture = new ListHandlerFixtures(ListHandlerFixtures.TestTypeEnum.Ok);
            var query   = fixture.Query;
            var sut     = new ListHandlerFixtures.ListHandlerMock(
                fixture.ReadOnlyRepository.Object,
                fixture.Mapper.Object);

            // Act
            var computed = await sut.Handle(query, default);

            // Assert
            Assert.NotNull(computed);
            Assert.Equal(fixture.QueryResult, computed.Data);
            Assert.Equal(fixture.TotalElements, computed.TotalElements);
            Assert.Equal(fixture.Query.Draw, computed.Draw);
            Assert.Equal(fixture.Query.Skip, computed.Skip);
            Assert.Equal(fixture.Query.Take, computed.Take);

            fixture.ReadOnlyRepository.VerifyAll();
            fixture.ReadOnlyRepository.VerifyNoOtherCalls();
        }