Esempio n. 1
0
        public async Task RandomShouldReturnViewModelWithCorrecArticle()
        {
            // ARRANGE
            const int requestedEntityIndex = 3;
            const int requestedEntityId    = requestedEntityIndex + 1;

            var configuration = new ConfigurationBuilder()
                                .AddInMemoryCollection(new KeyValuePair <string, string>[]
            {
                new KeyValuePair <string, string>("Articles:PageSize", "5"),
            })
                                .Build();

            var articleController =
                new ArticlesController(new FakeArticleService(), null, configuration)
                .WithClaimPrincipal("TEST_USERNAME");

            var fakeRandomValueProvider = new FakeRandomValueProvider
            {
                NextValue = requestedEntityIndex
            };

            // ACT
            var actionResult =
                Assert.IsType <ViewResult>(await articleController.Random(fakeRandomValueProvider));

            var model = Assert.IsType <ArticleDetailsServiceModel>(actionResult.Model);

            // ASSERT

            Assert.Equal(requestedEntityId, model.Id);
        }