예제 #1
0
        public void GetDetails_WithInvalidId_ShouldThrowNotFoundException()
        {
            // Arrange
            var sut = new GetExampleEntityDetailsQueryHandler(this.Context);
            var invalidExampleEntityId = 10;

            // Assert
            Should.Throw <NotFoundException>(async() =>
            {
                // Act
                var result
                    = await sut.Handle(new GetExampleEntityDetailsQuery {
                    EntityId = invalidExampleEntityId
                }, CancellationToken.None);
            });
        }
예제 #2
0
        public async Task GetDetails_WithValidId_ShouldReturnCorrectExampleEntity()
        {
            // Arrange
            var sut = new GetExampleEntityDetailsQueryHandler(this.Context);
            var validExampleEntityId = 1;

            // Act
            var result
                = await sut.Handle(new GetExampleEntityDetailsQuery { EntityId = validExampleEntityId }, CancellationToken.None);

            // Assert
            result.Id.ShouldBe(validExampleEntityId);

            result.Description.ShouldNotBeNull();
            result.ImageUrl.ShouldNotBeNull();
            result.UserId.ShouldBe("0001");
            result.UserName.ShouldBe("User 1");
        }