public async Task RetrieveInvalidRecord_DetailsCorrect()
        {
            // Arrange
            var testUrl = "www.pmichaels.net";
            var options = new DbContextOptionsBuilder <ResearchContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .EnableSensitiveDataLogging()
                          .Options;
            var researchContext    = new ResearchContext(options);
            var researchController = new ResearchController(researchContext);
            var research           = new Research()
            {
                Id        = 1,
                DateSaved = new DateTime(2018, 10, 24),
                Note      = "Useful site for programming and tech information",
                Read      = false,
                Url       = testUrl
            };

            var createResult = await researchController.Create(research);

            // Act
            var detailsResult = await researchController.Details(2);

            // Assert
            Assert.IsType <NotFoundResult>(detailsResult);
        }
        public static void Initialize(ResearchContext context)
        {
            context.Database.EnsureCreated();

            if (!context.ResearchLinks.Any())
            {
                var researchLinks = new Research[]
                {
                    new Research {
                        Url = "www.google.com", DateSaved = DateTime.Now, Note = "Generated Data", Read = false
                    },
                    new Research {
                        Url = "www.twitter.com", DateSaved = DateTime.Now, Note = "Generated Data", Read = false
                    },
                    new Research {
                        Url = "www.facebook.com", DateSaved = DateTime.Now, Note = "Generated Data", Read = false
                    },
                    new Research {
                        Url = "www.packtpub.com", DateSaved = DateTime.Now, Note = "Generated Data", Read = false
                    },
                    new Research {
                        Url = "www.linkedin.com", DateSaved = DateTime.Now, Note = "Generated Data", Read = false
                    },
                };
                foreach (Research research in researchLinks)
                {
                    context.ResearchLinks.Add(research);
                }
                context.SaveChanges();
            }
        }
Esempio n. 3
0
 public ResearchController(ResearchContext context)
 {
     _context = context;
 }