public void Ef_InserirPromocaoDesconto_test() { using (EfCommand cmd = new EfCommand()) { int pid = cmd.InserirPromocaoDesconto("2000-10-10 10:00:00", "3000-10-10 10:00:00", "Teste Promocao Temporal", "Baldes", "0,7"); Assert.AreEqual(3, pid); } }
public void CompareADO_VS_EF_Round2() { Stopwatch sw = new Stopwatch(); int MAX_RUNS = 50; int ignore = 0; // Test EF speed for InserirPreco followed by RemoverPreco long EFBestTime = int.MaxValue; sw.Start(); for (int i = 0; i < MAX_RUNS; i++) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); using (EfCommand cmd = new EfCommand()) { // inserir ignore = cmd.InserirPreco("Baldes", "9999" + i, "23:00:00", "3000-01-01 00:00:00"); } using (EfCommand cmd = new EfCommand()) { // remover o que inserimos ignore = cmd.RemoverPreco("Baldes", "9999" + i, "23:00:00", "3000-01-01 00:00:00"); } sw2.Stop(); EFBestTime = (sw2.ElapsedTicks < EFBestTime) ? sw2.ElapsedTicks : EFBestTime; } sw.Stop(); long EFtime = sw.ElapsedMilliseconds; // Test ADO.NET speed for InserirPreco followed by RemoverPreco sw.Reset(); sw.Start(); long ADOdotNETBestTime = int.MaxValue; for (int i = 0; i < MAX_RUNS; i++) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); using (AdoCommand cmd = new AdoCommand()) { // inserir ignore = cmd.InserirPreco("Baldes", "9999" + i, "23:00:00", "3000-01-01 00:00:00"); } using (AdoCommand cmd = new AdoCommand()) { // remover o que inserimos ignore = cmd.RemoverPreco("Baldes", "9999" + i, "23:00:00", "3000-01-01 00:00:00"); } sw2.Stop(); ADOdotNETBestTime = (sw2.ElapsedTicks < ADOdotNETBestTime) ? sw2.ElapsedTicks : ADOdotNETBestTime; } sw.Stop(); long ADOdotNETtime = sw.ElapsedMilliseconds; Console.WriteLine( "EF -> Total time: " + EFtime + "ms Best time: " + EFBestTime + "ticks" + "\nADO.NET -> Total time: " + ADOdotNETtime + "ms Best time: " + ADOdotNETBestTime + "ticks" ); }
public void Ef_RemoverAluguer_test() { using (EfCommand cmd = new EfCommand()) { var aluguerView = cmd.GetContext().AluguerView; String id = aluguerView.First().id; int row = cmd.RemoverAluguer(id); var selectAluguer = aluguerView.Where((al) => al.id == id); } }
public void Ef_InserirAluguer_test() { using (EfCommand cmd = new EfCommand()) { var aluguerView = cmd.GetContext().AluguerView; String aluguerId = cmd.InserirAluguer("1", "1", "1", "2187-01-01 00:00:00", "01:00:00", "10,0", ""); var selectAluguer = cmd.GetContext().AluguerView.Where((al) => al.id == aluguerId); Assert.IsTrue(selectAluguer.Count() != 0); } }
public void Ef_RemoverPromocaoDesconto_test() { using (EfCommand cmd = new EfCommand()) { var promocao = cmd.GetContext().PromocaoDesconto.Where(p => p.pId == 2); Assert.IsTrue(promocao.Count() == 1); int row = cmd.RemoverPromocaoDesconto("2"); Assert.AreEqual(3, row); var promocao2 = cmd.GetContext().PromocaoDesconto.Where(p => p.pId == 2); Assert.IsTrue(promocao2.Count() == 0); } }
public void Ef_InserirPreco_test() { String tipo = "Baldes", valor = "20,0", duracao = "2:00:00", validade = "3000-10-10 10:00:00"; using (EfCommand cmd = new EfCommand()) { var preco1 = cmd.GetContext().Preco.Where((prec) => prec.tipo == tipo && prec.valor == 20); Assert.IsTrue(preco1.Count() == 0); int row = cmd.InserirPreco(tipo, valor, duracao, validade); Assert.AreEqual(1, row); var preco2 = cmd.GetContext().Preco.Where((prec) => prec.tipo == tipo && prec.valor == 20); Assert.IsFalse(preco1.Count() == 0); } }
public void CompareADO_VS_EF() { Stopwatch sw = new Stopwatch(); int MAX_RUNS = 50; // Test EF speed for EquipamentosSemAlugueresNaUltimaSemana long EFBestTime = int.MaxValue; sw.Start(); for (int i = 0; i < MAX_RUNS; i++) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); using (EfCommand cmd = new EfCommand()) { cmd.EquipamentosSemAlugueresNaUltimaSemana(); } sw2.Stop(); EFBestTime = (sw2.ElapsedTicks < EFBestTime) ? sw2.ElapsedTicks : EFBestTime; } sw.Stop(); long EFtime = sw.ElapsedMilliseconds; // Test ADO.NET speed for EquipamentosSemAlugueresNaUltimaSemana sw.Reset(); sw.Start(); long ADOdotNETBestTime = int.MaxValue; for (int i = 0; i < MAX_RUNS; i++) { Stopwatch sw2 = new Stopwatch(); sw2.Start(); using (AdoCommand cmd = new AdoCommand()) { cmd.EquipamentosSemAlugueresNaUltimaSemana(); } sw2.Stop(); ADOdotNETBestTime = (sw2.ElapsedTicks < ADOdotNETBestTime) ? sw2.ElapsedTicks : ADOdotNETBestTime; } sw.Stop(); long ADOdotNETtime = sw.ElapsedMilliseconds; Console.WriteLine( "EF -> Total time: " + EFtime + "ms Best time: " + EFBestTime + "ticks" + "\nADO.NET -> Total time: " + ADOdotNETtime + "ms Best time: " + ADOdotNETBestTime + "ticks" ); }
public void Ef_ActualizarPreco_test() { String nome = "Baldes", preco = "5,00", duracao = "00:45:00", validade = "3000-10-10 10:00:00"; using (EfCommand cmd = new EfCommand()) { var duracaoParsed = TimeSpan.Parse(duracao); var preco1 = cmd.GetContext().Preco.Where((prec) => prec.tipo == nome && prec.valor == 5 && prec.duracao == duracaoParsed); Assert.IsTrue(preco1.Count() == 1); int row = cmd.ActualizarPreco(nome, preco, duracao, validade, "5,00", "00:30:00", "3000-10-10 10:00:00"); Assert.AreEqual(2, row); var preco2 = cmd.GetContext().Preco.Where((prec) => prec.tipo == nome && prec.valor == 5 && prec.duracao == duracaoParsed); Assert.IsFalse(preco1.Count() == 1); } }
public void Ef_ActualizarPromocaoDesconto_test() { String id = "4"; String desc = "Promocao Temporal Ef Actualizada"; using (EfCommand cmd = new EfCommand()) { var promocao = cmd.GetContext().Promocao.Where(p => p.pId == 4 && p.descr == desc); Assert.IsTrue(promocao.Count() == 0); int row = cmd.ActualizarPromocaoDesconto(id, "2000-10-10 10:00:00", "3000-10-10 10:00:00", desc, "0,1"); Assert.AreEqual(2, row); var promocao2 = cmd.GetContext().Promocao.Where(p => p.pId == 4 && p.descr == desc); Assert.IsTrue(promocao2.Count() == 1); } }
public void Ef_RemoverPreco_test() { String nome = "Baldes", preco = "7,00", duracao = "00:50:00", validade = "3000-10-10 10:00:00"; using (EfCommand cmd = new EfCommand()) { var duracaoParsed = TimeSpan.Parse(duracao); var preco1 = cmd.GetContext().Preco.Where((prec) => prec.tipo == nome && prec.valor == 7 && prec.duracao == duracaoParsed); Assert.IsTrue(preco1.Count() > 0); int row = cmd.RemoverPreco(nome, preco, duracao, validade); Assert.AreEqual(1, row); var preco2 = cmd.GetContext().Preco.Where((prec) => prec.tipo == nome && prec.valor == 7 && prec.duracao == duracaoParsed); Assert.IsTrue(preco1.Count() == 0); } }
public void Ef_InserirAluguerComNovoCliente_test() { using (EfCommand cmd = new EfCommand()) { //Select Cliente var cliente = cmd.GetContext().Cliente.Where((c) => c.nif == 123132321); Assert.IsTrue(cliente.Count() == 0); String aluguerId = cmd.InserirAluguerComNovoCliente("123132321", "Antonio Costa", "Belem", "1", "1", "2187-01-01 00:00:00", "01:00:00", "10,0", ""); //Select Cliente var cliente2 = cmd.GetContext().Cliente.Where((c) => c.nif == 123132321); Assert.IsFalse(cliente2.Count() == 0); //Select Aluguer var selectAluguer = cmd.GetContext().AluguerView.Where((al) => al.id == aluguerId); Assert.IsTrue(selectAluguer.Count() != 0); } }
public static CommandLineOptions Parse(params string[] args) { var options = new CommandLineOptions(); var app = new CommandLineApplication { #if NET451 Name = "ef", #else Name = "ef", #endif FullName = "Entity Framework Core Command Line Tools" }; app.HelpOption(); app.VersionOption(Program.GetVersion); var verbose = app.Option("--verbose", "Show verbose output", inherited: true); var noColor = app.Option("--no-color", "Do not use color in console output"); // so "WriteLogo" gets the right option set before parsing the remainder of the args if (args.Any(a => a.Equals("--no-color"))) { Reporter.Use(new ConsoleReporter()); } var prefixOutput = app.Option("--prefix-output", "(internal flag) prefix output"); prefixOutput.ShowInHelpText = false; if (args.Any(a => a.Equals("--prefix-output"))) { Reporter.Use(new PrefixConsoleReporter()); } // required var assembly = app.Option("--assembly <assembly>", "The assembly file to load.", inherited: true); #if NET451 var appConfig = app.Option("--config <configfile>", "The application config file", inherited: true); var noAppDomain = app.Option("--no-appdomain", "Do not use app domains to execute the command"); #endif // common options var startupAssembly = app.Option("--startup-assembly <assembly>", "The assembly file containing the startup class.", inherited: true); var dataDirectory = app.Option("--data-dir <dir>", "The folder used as the data directory (defaults to current working directory).", inherited: true); var projectDirectory = app.Option("--project-dir <dir>", "The folder used as the project directory (defaults to current working directory).", inherited: true); var contentRootPath = app.Option("--content-root-path <dir>", "The folder used as the content root path for the application (defaults to application base directory).", inherited: true); var rootNamespace = app.Option("--root-namespace <namespace>", "The root namespace of the target project (defaults to the project assembly name).", inherited: true); var environment = app.Option( "-e|--environment <environment>", "The environment to use. If omitted, \"Development\" is used.", inherited: true); EfCommand.Configure(app, options); var result = app.Execute(args); if (result != 0) { return(null); } options.IsHelp = app.IsShowingInformation; options.Verbose = verbose.HasValue(); options.NoColor = noColor.HasValue(); options.Assembly = assembly.Value(); options.StartupAssembly = startupAssembly.Value(); options.DataDirectory = dataDirectory.Value(); options.ProjectDirectory = projectDirectory.Value(); options.ContentRootPath = contentRootPath.Value(); options.RootNamespace = rootNamespace.Value(); options.EnvironmentName = environment.Value(); #if NET451 options.AppConfigFile = appConfig.Value(); options.NoAppDomain = noAppDomain.HasValue(); #endif return(options); }