private static void CreateUrl() { IRepository repository = new Repository(SessionFactoryProvider); var q = (from code in repository.AsQueryable<ResponseCodes>() where code.ResponseCode == 501 select code).Single(); using (var transaction = new TransactionScope()){ var ses = new Sesions { ExecutionTime = 4525, CreationTime = DateTime.Now, userIP = "asad" }; repository.Save(ses); var url = new URLs { url = new Uri("http://www.google.lt"), sesion = ses, }; repository.Save(url); var response = new Responses { ResponseTime = 12345, URL = url, ResponseCode = q, RequestStartTime = DateTime.Now }; repository.Save(response); repository.Commit(); transaction.Complete(); } Sesions q2 = (from ses in repository.AsQueryable<Sesions>() where ses.userIP == "asad" select ses).Single(); //ISesionToXML s2x = new SesionToXML(); //s2x.ConvertSesionToXML(q2, "C:/hugas.xml"); }
public void NewProgramSesion() { newSesion.CreationTime = DateTime.Now; newSesion.userIP = ip; IRepository repository = new Repository(SessionFactoryProvider); repository.Save(newSesion); repository.Commit(); foreach (string url in urls) { if(url != "") if (IsValidUrl(url)) { Uri uri = new Uri(url, UriKind.RelativeOrAbsolute); ProgramManager pm = new ProgramManager(uri, newSesion); pm.Execute(amount, time, buffer); } else return; } buffer.Write(); var t = DateTime.Now - newSesion.CreationTime; var q = (from sesion in repository.AsQueryable<Sesions>() where sesion == newSesion select sesion).Single(); q.ExecutionTime = t.Value.Seconds + t.Value.Minutes * 60 + t.Value.Hours * 3600; repository.Save(q); repository.Commit(); if (onSesionEnd != null) onSesionEnd(q.ExecutionTime.ToString()); //Thread.Sleep(3000); //ISesionToXML s2x = new SesionToXML(); //s2x.ConvertSesionToXML(newSesion, "C:/hugas.xml"); }
public ProgramManager(Uri uri, Sesions sesion) { responsesGotten = 0; url = new URLs(); url.sesion = sesion; url.url = uri; IRepository repository = new Repository(SessionFactoryProvider); repository.Save(url); repository.Commit(); }
public void Save_MessageSet_SetCorrectly() { //Arrange const string messageSent = "Called from save"; var loggerMock = new Mock<ILogger>(); IRepository repository = new Repository(loggerMock.Object); //Act repository.Save(); //Assert Assert.AreEqual(messageSent, repository.GetMessage()); }
public void Save_LoggerCalledCorrecty_CalledWithCorrectMessage() { //Arrange const string messageSent = "Called from save"; var loggerMock = new Mock<ILogger>(); IRepository repository = new Repository(loggerMock.Object); //Act repository.Save(); //Assert loggerMock.Verify(logger => logger.Log(messageSent)); }