Esempio n. 1
0
        public async Task PatchWiki204TestAsync(string wikiURL)
        {
            string dbString = Guid.NewGuid().ToString();

            //ARRANGE
            using var context = InMemoryDbContextFactory.GetViewzDbContext(dbString);
            IMdToHtmlAndContentsFactory factory = new MdToHtmlAndContentsFactory();
            var wrepo           = new WikiRepositoryStoring(context, factory);
            var prepo           = new PageRepositoryStoring(context, factory);
            var wiki_controller = new WikiController(wrepo, prepo, w_logger);
            var wiki            = new ViewzApi.Models.Wiki()
            {
                PageName    = "I'm Hungry",
                Description = "This is a description"
            };

            var WIKI = await context.Wiki.Where(w => w.Url == wikiURL).SingleOrDefaultAsync();

            //ACT
            var status = await wiki_controller.PatchAsync(wikiURL, wiki);

            if (WIKI != null)
            {
                //ASSERT
                Assert.IsType <NoContentResult>(status);
            }
            else
            {
                Assert.IsType <NotFoundResult>(status);
            }
        }
Esempio n. 2
0
        public async Task PostWikiTestAsync(string wikiURL)
        {
            string dbString = Guid.NewGuid().ToString();

            //ARRANGE
            using var context = InMemoryDbContextFactory.GetViewzDbContext(dbString);
            IMdToHtmlAndContentsFactory factory = new MdToHtmlAndContentsFactory();
            var prepo           = new PageRepositoryStoring(context, factory);
            var wrepo           = new WikiRepositoryStoring(context, factory);
            var wiki_controller = new WikiController(wrepo, prepo, w_logger);

            var wiki = await context.Wiki.Where(w => w.Url == wikiURL).SingleOrDefaultAsync();

            var content = new PageHtmlContent();
            var W       = new ViewzApi.Models.Wiki()
            {
                Url         = wikiURL,
                Description = "",
                PageName    = wikiURL
            };

            var status = await wiki_controller.PostAsync(wikiURL, W);

            if (wiki == null)
            {
                //ASSERT
                Assert.IsType <CreatedAtActionResult>(status);
            }
            else
            {
                Assert.IsType <ConflictObjectResult>(status);
            }
        }