コード例 #1
0
        public void CantGetInexistingPlaceholder()
        {
            IPlaceholderRepository repository = A.Fake <IPlaceholderRepository>();

            A.CallTo(() => repository.Find(A <string> ._)).Returns(null);
            ILogger <PlaceholderService> logger = A.Fake <ILogger <PlaceholderService> >();

            PlaceholderService sut = new PlaceholderService(repository, logger);

            Placeholder result = sut.Get("test");

            result.Should().Be(null);
        }
コード例 #2
0
        public void CanGetAllPlaceholders()
        {
            List <Placeholder> placeholders = new List <Placeholder> {
                new Placeholder("1"), new Placeholder("2")
            };
            IPlaceholderRepository repository = A.Fake <IPlaceholderRepository>();

            A.CallTo(() => repository.Find()).Returns(placeholders);
            ILogger <PlaceholderService> logger = A.Fake <ILogger <PlaceholderService> >();

            PlaceholderService sut = new PlaceholderService(repository, logger);

            List <Placeholder> result = sut.Get();

            result.Should().NotContainNulls();
            result.Should().ContainEquivalentOf(new Placeholder("1"));
            result.Should().ContainEquivalentOf(new Placeholder("2"));
        }