Exemple #1
0
        public async Task PostsToBannerAndChecksGoodHtmlReturned()
        {
            var options = new DbContextOptionsBuilder <IBannersContext>()
                          .UseInMemoryDatabase(databaseName: "TestFixturedatabase2")
                          .Options;

            using (var context = new IBannersContext(options))
            {
                var controller = new BannersController(context);
                var banner     = new Banner {
                    Id = 1, Html = "&lt;html&gt;&lt;body&gt;&lt;h2 title=&quot;I'm a header&quot;&gt;The title Attribute&lt;/h2&gt;&lt;p title=&quot;I'm a tooltip&quot;&gt;Mouse over this paragraph, to display the title attribute as a tooltip.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", Created = DateTime.Parse("2015-12-08T15:15:19Z")
                };

                var a = controller.PostBanner(banner);

                var r = await controller.GetBannerHtml(1) as ContentResult;

                string expected = @"<html><body><h2 title=""I'm a header"">The title Attribute</h2><p title=""I'm a tooltip"">Mouse over this paragraph, to display the title attribute as a tooltip.</p></body></html>";
                Assert.AreEqual(expected, r.Content);
            }
        }
Exemple #2
0
        public async Task PostsToBannerAndChecksValueReturnedIsSameAsGet()
        {
            var options = new DbContextOptionsBuilder <IBannersContext>()
                          .UseInMemoryDatabase(databaseName: "TestFixturedatabase")
                          .Options;

            using (var context = new IBannersContext(options))
            {
                var controller = new BannersController(context);
                var banner     = new Banner {
                    Id = 1, Html = "&lt;html&gt;&lt;body&gt;&lt;h2 title=&quot;I'm a header&quot;&gt;The title Attribute&lt;/h2&gt;&lt;p title=&quot;I'm a tooltip&quot;&gt;Mouse over this paragraph, to display the title attribute as a tooltip.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", Created = DateTime.Parse("2015-12-08T15:15:19Z")
                };
                var response = controller.PostBanner(banner);
                var res      = response.Result as CreatedAtActionResult;

                var r = await controller.GetBanner(1) as OkObjectResult;

                Assert.AreEqual(banner, res.Value);
                Assert.AreEqual(banner, r.Value);
            }
        }
Exemple #3
0
 public BannersController(IBannersContext context)
 {
     _context = context;
 }