public void WebsiteRepository_Add() { //Arrange var dto = new WebsiteDto() { Id = 1032, Hostname = "usa.gov", LastScan = DateTime.Today.AddDays(-10) }; var unitOfWork = new UnitOfWork(Database); var unitOfWorkFactory = new Mock <IUnitOfWorkFactory>(); unitOfWorkFactory.Setup(x => x.GetUnitOfWork()).Returns(unitOfWork); var repository = new WebsiteRepository(new DatabaseFactory(Database)) { UnitOfWorkFactory = unitOfWorkFactory.Object }; //Act repository.Add(dto); var entityToAssert = Database.Websites.Find(1032); //Assert Assert.IsNotNull(entityToAssert); Assert.AreEqual(1032, entityToAssert.Id); Assert.AreEqual("usa.gov", entityToAssert.Hostname); Assert.AreEqual(DateTime.Today.AddDays(-10), entityToAssert.LastScan); }
public void AddWebsiteToCollection() { var website = new Website() { MainUrl = Website.MainUrl, CartButtonXPatch = Website.CartButtonXPatch, NameXPath = Website.NameXPath, PriceXPath = Website.PriceXPath }; _websiteRepository.Add(website); WebsiteCollection.Add(website); }
public void TestAddWebsiteToSpecificationBase() { Website response; var website = new WebsiteBuilder().FacebookWebsite().Build(); try { response = websiteRepo.Add(website); websiteRepo.Save(); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); throw; } Assert.IsNotNull(response); Assert.AreEqual(website.CompanyName, response.CompanyName); Assert.AreEqual(website.WebsiteUrl, response.WebsiteUrl); }
public void AddWebsitesFromCsv(string rawCsv) { var websiteEntries = CsvService.ParseWebsiteCsvList(rawCsv); var hostnames = websiteEntries.Select(x => x.Hostname.ToLower()).ToList(); var doWebsitesExist = WebsiteRepository.DoWebsitesExist(hostnames); foreach (var websiteEntry in websiteEntries) { if (!doWebsitesExist[websiteEntry.Hostname.ToLower()]) { var websiteCategory = WebsiteCategoryService.GetOrCreateWebsiteCategory(websiteEntry); WebsiteRepository.Add(new WebsiteDto() { Id = WebsiteService.GetNextId(), Hostname = websiteEntry.Hostname.ToLower(), LastScan = DateTime.MinValue, Status = StatusType.NEW, CategoryId = websiteCategory.Id }); } } }