コード例 #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"));
        }
コード例 #3
0
 /// <summary>
 /// Инициализирует новый экземпляр класса <see cref="PlaceholderService"/>.
 /// </summary>
 /// <param name="placeholderRepository">Хранилище Placeholder.</param>
 /// <param name="logger">Абстракция над сервисом журналирования.</param>
 public PlaceholderService(IPlaceholderRepository placeholderRepository, ILogger <PlaceholderService> logger)
 {
     this.placeholderRepository = placeholderRepository;
     this.logger = logger;
 }