Beispiel #1
0
        public void GetByFilterAsync_Filter_Category()
        {
            var keys = new string[]
            {
                FakeHelper.Key,
                FakeHelper.Key
            };

            var book = BookMock.Create(keys[0])
                       .Default()
                       .WithCategory()
                       .Build();

            MockRepository.Add(book);
            MockRepository.Add(BookMock.Get(keys[1]));

            var pagination = PagedRequestMock.Create(BookFilterPayloadMock.Get());

            pagination.Filter.Category = Fake.GetCategoryName(keys[0]);

            var proxy = GetByFilterAsync(pagination);

            proxy.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(keys[0]);

            var pagedProxyExpected = PagedResponseMock.Create(proxy1);

            proxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }
Beispiel #2
0
        public void GetByFilterAsync_Book_FlagTableAtuthor_WithAuthor()
        {
            var keys = new string[]
            {
                FakeHelper.Key,
                FakeHelper.Key
            };
            var book1 = BookMock.Get(keys[0]);

            book1.Author = BookAuthorMock.Get(keys[0]);

            MockRepository.Add(book1);
            MockRepository.Add(BookMock.Get(keys[1]));

            var pagination = PagedRequestMock.Create(BookFilterPayloadMock.Get());

            var settings = Settings.Empty;

            settings.FeatureFlags.TryAdd(FeatureFlags.AddTableAtuthor, true);

            var pagedProxy = GetByFilterAsync(pagination, settings);

            pagedProxy.Should().NotBeNull();

            var proxy = GetByFilterAsync(pagination);

            proxy.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(keys[0]);
            var proxy2 = BookProxyMock.Get(keys[1]);

            var pagedProxyExpected = PagedResponseMock.Create(proxy1, proxy2);

            proxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }
Beispiel #3
0
        public void GetByFilterAsync_Filter_Language()
        {
            var keys = new string[]
            {
                FakeHelper.Key,
                FakeHelper.Key
            };

            var book = BookMock.Get(keys[0]);

            book.Language = Language.Portuguese;

            MockRepository.Add(book);
            MockRepository.Add(BookMock.Get(keys[1]));

            var pagination = PagedRequestMock.Create(BookFilterPayloadMock.Get());

            pagination.Filter.Language = book.Language;

            var proxy = GetByFilterAsync(pagination);

            proxy.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(keys[0]);

            proxy1.Language = Language.Portuguese;

            var pagedProxyExpected = PagedResponseMock.Create(proxy1);

            proxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }
Beispiel #4
0
        public void GetAllAsync_Book_FlagTableAtuthor_WithoutAuthor()
        {
            var key  = FakeHelper.Key;
            var book = BookMock.Get(key);

            book.Author = null;
            MockRepository.Add(book);

            var settings = Settings.Empty;

            settings.FeatureFlags.TryAdd(FeatureFlags.AddTableAtuthor, true);

            var pagedProxy = GetAllAsync(settings);

            pagedProxy.Should().NotBeNull();

            var entity = Db.Books.FirstOrDefault(x => x.Title == Fake.GetTitle(key));

            entity.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(key);

            proxy1.Id     = entity.Id;
            proxy1.Author = null;

            var pagedProxyExpected = PagedResponseMock.Create(proxy1);

            pagedProxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }
Beispiel #5
0
        public void GetByIdAsync_Book_FlagTableAtuthor_WithAuthor()
        {
            var key  = FakeHelper.Key;
            var book = BookMock.Get(key);

            book.Author = BookAuthorMock.Get(key);
            MockRepository.Add(book);

            var settings = Settings.Empty;

            settings.FeatureFlags.TryAdd(FeatureFlags.AddTableAtuthor, true);

            var proxy = GetByIdAsync(book.Id, settings);

            proxy.Should().NotBeNull();

            var entity = Db.Books.FirstOrDefault(x => x.Title == Fake.GetTitle(key));

            entity.Should().NotBeNull();

            var proxyExpected = BookProxyMock.Get(key);

            proxyExpected.Id = entity.Id;
            proxy.Should().BeEquivalentToModel(proxyExpected);
        }
Beispiel #6
0
        public void GetByIdAsync_Book_Valid()
        {
            var key  = FakeHelper.Key;
            var book = BookMock.Get(key);

            MockRepository.Add(book);

            var proxy = GetByIdAsync(book.Id);

            proxy.Should().NotBeNull();

            var entity = Db.Books.FirstOrDefault(x => x.Title == Fake.GetTitle(key));

            entity.Should().NotBeNull();

            var proxyExpected = BookProxyMock.Get(key);

            proxyExpected.Id = entity.Id;
            proxy.Should().BeEquivalentToModel(proxyExpected);
        }
Beispiel #7
0
        public void GetAllAsync_Book_Valid()
        {
            var key  = FakeHelper.Key;
            var book = BookMock.Get(key);

            MockRepository.Add(book);

            var pagedProxy = GetAllAsync();

            pagedProxy.Should().NotBeNull();

            var entity = Db.Books.FirstOrDefault(x => x.Title == Fake.GetTitle(key));

            entity.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(key);

            proxy1.Id = entity.Id;

            var pagedProxyExpected = PagedResponseMock.Create(proxy1);

            pagedProxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }
Beispiel #8
0
        public void GetByFilterAsync_Valid()
        {
            var keys = new string[]
            {
                FakeHelper.Key,
                FakeHelper.Key
            };

            MockRepository.Add(BookMock.Get(keys[0]));
            MockRepository.Add(BookMock.Get(keys[1]));

            var pagination = PagedRequestMock.Create(BookFilterPayloadMock.Get());

            var proxy = GetByFilterAsync(pagination);

            proxy.Should().NotBeNull();

            var proxy1 = BookProxyMock.Get(keys[0]);
            var proxy2 = BookProxyMock.Get(keys[1]);

            var pagedProxyExpected = PagedResponseMock.Create(proxy1, proxy2);

            proxy.Should().BeEquivalentToModel(pagedProxyExpected);
        }