Beispiel #1
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 #2
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();
        }