public async Task ReadAll_Any_ReturnsAllEntitiesFromRepository()
        {
            // Arrange
            var expected = new[]
            {
                new AnyEntity
                {
                    Id        = 1,
                    AnyString = "AnyString"
                },
                new AnyEntity
                {
                    Id        = 2,
                    AnyString = "AnyString"
                }
            };

            A.CallTo(() => repository.GetAll()).Returns(expected);

            // Act
            var result = (await controller.ReadAll()).Result as OkObjectResult;

            // Assert
            result.Should().NotBeNull();
            result.Value.Should().Be(expected);
        }
示例#2
0
        public void GetAll_Default_ReturnsAll()
        {
            // Arrange
            var expected = new[]
            {
                new AnyEntity
                {
                    Id        = 1,
                    AnyString = "Any"
                },
                new AnyEntity
                {
                    Id        = 2,
                    AnyString = "Any"
                }
            };

            dbContext.AnyEntities.AddRange(expected);
            dbContext.SaveChanges();

            // Act
            var actual = repository.GetAll();

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
        public void ReadAll_Any_ReturnsAllEntitiesFromRepository()
        {
            var expected = new[]
            {
                new AnyEntity
                {
                    Id        = 1,
                    AnyString = "AnyString"
                },
                new AnyEntity
                {
                    Id        = 2,
                    AnyString = "AnyString"
                }
            }.AsEnumerable();

            A.CallTo(() => repository.GetAll()).Returns(expected);

            var result = controller.ReadAll().Result as OkObjectResult;

            result.Should().NotBeNull();
            result.Value.Should().Be(expected);
        }