private void del_Click(object sender, RoutedEventArgs e) { try { CTest test = (CTest)data.SelectedItem; data.Items.RemoveAt(data.SelectedIndex); string sql = "DELETE FROM test_table WHERE nb_field = " + test.nb_field; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); } catch (NullReferenceException) { MessageBox.Show("Выберите элемент!"); } catch (ArgumentOutOfRangeException) { MessageBox.Show("Выберите элемент!"); } catch (SQLiteException) { MessageBox.Show("Пусто!"); } }
public void ResolveAllOnlyReturnsInterfaceRegistrations() { ITest iTest; ATest objA = new ATest(); BTest objB = new BTest(); CTest objC = new CTest(); objA.Strtest = "Hi"; UnityContainer uc1 = new UnityContainer(); uc1.RegisterType <ITest, ATest>(); iTest = objA; uc1.RegisterInstance("ATest", iTest); iTest = objB; uc1.RegisterInstance("BTest", iTest); iTest = objC; uc1.RegisterInstance("CTest", iTest); List <ATest> list = new List <ATest>(uc1.ResolveAll <ATest>()); List <ITest> list3 = new List <ITest>(uc1.ResolveAll <ITest>()); Assert.AreEqual(0, list.Count); Assert.AreEqual(3, list3.Count); }
public void ResolveAllOnlyReturnsInterfaceRegistrations() { ITest iTest; ATest objA = new ATest(); BTest objB = new BTest(); CTest objC = new CTest(); objA.Strtest = "Hi"; UnityContainer uc1 = new UnityContainer(); uc1.RegisterType<ITest, ATest>(); iTest = objA; uc1.RegisterInstance("ATest", iTest); iTest = objB; uc1.RegisterInstance("BTest", iTest); iTest = objC; uc1.RegisterInstance("CTest", iTest); List<ATest> list = new List<ATest>(uc1.ResolveAll<ATest>()); List<ITest> list3 = new List<ITest>(uc1.ResolveAll<ITest>()); Assert.AreEqual(0, list.Count); Assert.AreEqual(3, list3.Count); }
private void del_Click(object sender, RoutedEventArgs e) { string db_name = "C:\\Users\\Admin\\Documents\\ри-89\\progLab4\\db.db"; SQLiteConnection m_dbConnection; m_dbConnection = new SQLiteConnection("Data Source=" + db_name + ";Version=3;"); m_dbConnection.Open(); CTest redData = (CTest)data.SelectedItem; string sql = "DELETE FROM fio WHERE number = " + redData.number.ToString(); string sql1 = "DELETE FROM rate WHERE number = " + redData.number.ToString(); SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); SQLiteCommand command1 = new SQLiteCommand(sql1, m_dbConnection); command1.ExecuteNonQuery(); if (data.SelectedIndex > -1) { data.Items.RemoveAt(data.SelectedIndex); } data.Items.Refresh(); m_dbConnection.Close(); }
public MainWindow() { InitializeComponent(); string db_name = "C:\\Users\\Admin\\Documents\\ри-89\\progLab4\\db.db"; SQLiteConnection m_dbConnection; m_dbConnection = new SQLiteConnection("Data Source=" + db_name + ";Version=3;"); m_dbConnection.Open(); string sql = "SELECT * FROM fio ORDER BY number"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); string sql1 = "SELECT * FROM rate ORDER BY number"; SQLiteCommand command1 = new SQLiteCommand(sql1, m_dbConnection); SQLiteDataReader reader1 = command1.ExecuteReader(); while (reader.Read() && reader1.Read()) { var datag = new CTest { number = int.Parse(reader["number"].ToString()), fio = reader["fio"].ToString(), rateM = int.Parse(reader1["rateM"].ToString()), rateP = int.Parse(reader1["rateP"].ToString()) }; data.Items.Add(datag); } reader.Close(); reader1.Close(); data.Items.Refresh(); m_dbConnection.Close(); }
public static void ClassTest() { /* * // < class Consturctor with new > * * 1. new Type 뒤에는 반드시 (), [], {}가 필요하다. * new Type(...) * new Type[...] * new Type{...} * * 2. 클래스의 암시적 기본 생성자는 모든 멤버 데이터를 0 or null로 초기화한다. */ { CTest t = new CTest(1); Console.WriteLine("CTest m_Value: {0}, {1}", t.m_Value1, t.m_Value2); foreach (int i in t) { Console.WriteLine("{0}", i); } foreach (int i in t.DoForeach()) { Console.WriteLine("{0}", i); } } { CParent p = new CTest(); p.Func(); p.VFunc(); } }
// [ValidateAntiForgeryToken] public ActionResult Create(int[] TestWordsParameters, string title, int rstatus, int time) //string Title, bool? TotalTime , bool? Second, DateTime? Time { // string name = Request.Form["Title"].ToString(); CTest test = new CTest(); if (TestWordsParameters != null) { test.CTNote = title; if (rstatus == 1) { test.Score = time; test.TestTime = true; } else if (rstatus == 2) { test.Score = time; test.TimePerWord = true; } for (int j = 0; j < TestWordsParameters.Length; j++) { var r = TestWordsParameters[j]; ChoiceTest wt = new ChoiceTest(); wt.FChoicerID = r; test.ChoiceTests.Add(wt); // parent.childs.Add(child obj) } test.FCTuserID = userid; db.CTests.Add(test); db.SaveChanges(); } // ViewBag.FWTUserID = new SelectList(db.Users, "UserID", "Forename", wTest.FWTUserID); return(RedirectToAction("Create")); }
public async Task Timeout() { string json = "{\"Test:\"Success\"}"; var stopwatch = new Stopwatch(); await CTest <FakeServerContext> .Given(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse(json) .WithMethod(HttpMethod.Get) .WithBeforeReturn(() => Thread.Sleep(1000)) )) .WhenAsync(async i => { var client = i.Context.FakeServer.GetClient(); client.Timeout = TimeSpan.FromMilliseconds(100); try { await i.MakeTheRequest(client, "http://fake.local/123", HttpMethod.Get); } catch (Exception e) { i.Context.Exception = e; } }) .Then(t => Assert.True(t.Context.Exception is TaskCanceledException)) .ExecuteAsync(); }
private void button2_Click(object sender, EventArgs e) { // 非靜態方法, 需造一個物件 string sName = "Chien"; CTest obj = new CTest(); button2.Text = obj.Hello(sName); }
public ActionResult DeleteConfirmed(int id) { CTest cTest = db.CTests.Find(id); db.CTests.Remove(cTest); db.SaveChanges(); return(RedirectToAction("Index")); }
public void SourceTyped() { _mockContext.Setup(x => x.Source).Returns(3); var graph = new CTest <int>(); ((IDIObjectGraphBase)graph).Context = _context; graph.Source.ShouldBe(3); }
public void GivenTheUserLogsInAsAdmin() { CTest.StartApplication <LoginPage>(); // logs into https://news.yahoo.com/ Thread.Sleep(2000); IWebElement videoLink = CTest.Driver.FindElement(By.CssSelector("a[title = 'Videos']")); // clicks a link videoLink.Click(); Thread.Sleep(2000); }
public async Task Test1() { await CTest <TestContext> .GivenAsync(g => Task.FromResult(g.Context.FirstValue = 1)) .And(g => g.Context.SecondValue = 10) .WhenAsync(w => Task.FromResult(w.Context.Added = w.Context.FirstValue + w.Context.SecondValue)) .And(w => w.Context.Final = w.Context.Added / 2d) .Then(t => Assert.Equal(5.5d, t.Context.Final)) .ExecuteAsync(); }
public async Task EntityCreatesWithIdAndVersion() { await CTest <EntityContext <EntityClass> > .Given(a => a.EntityService()) .WhenAsync(i => i.CreateTheEntity()) .Then(t => t.VersionIs(1)) .And(t => t.IdIsGenerated()) .And(t => t.EventIsRaised($"{typeof(EntityClass).Name}_Created")) .ExecuteAsync(); }
public async Task Test1() { await CTest <TestContext> .Given(g => g.Context.FirstValue = 1) .And(g => g.AnotherValue(10)) .WhenAsync(async w => await w.IAddTheValues()) .AndAsync(async w => await w.IDivideBy(2)) .ThenAsync(async t => await t.TheAnswerIs(5.5d)) .ExecuteAsync(); }
public async Task NullBody() { await CTest <FakeServerContext> .Given(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse(null) .WithStatusCode(HttpStatusCode.Accepted))) .WhenAsync(i => i.MakeTheRequest("http://fake.local/123")) .ThenAsync(t => t.JsonIsReturned(null)) .And(t => t.StatusCodeIs(HttpStatusCode.Accepted)) .ExecuteAsync(); }
public async Task SimpleUri() { string json = "{\"Test:\"Success\"}"; await CTest <FakeServerContext> .Given(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse(json))) .WhenAsync(i => i.MakeTheRequest("http://fake.local/123")) .ThenAsync(t => t.JsonIsReturned(json)) .ExecuteAsync(); }
public async Task Test1() { await CTest <TestContext> .GivenAsync(g => g.AValue()) .AndAsync(g => g.AnotherValue(10)) .WhenAsync(w => w.IAddTheValues()) .AndAsync(w => w.IDivideBy(2)) .ThenAsync(t => t.TheAnswerIs(5.5d)) .AndAsync(t => t.True()) .ExecuteAsync(); }
public ActionResult Edit([Bind(Include = "CTestID,FCTuserID,StartTime,EndTime,Score,CTNote,Status,TestTime,TimePerWord,Minutes,Seconds,Duration")] CTest cTest) { if (ModelState.IsValid) { cTest.FCTuserID = userid; db.Entry(cTest).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } // ViewBag.FCTuserID = new SelectList(db.Users, "UserID", "Forename", cTest.FCTuserID); return(View(cTest)); }
public async Task DisposeIsCalled() { bool disposed = false; Action <bool> setDisposed = d => disposed = d; await CTest <DisposableContext> .Given(q => q.Context.Disposer = setDisposed) .When(q => {}) .Then(q => {}) .ExecuteAsync(); Assert.True(disposed); }
public async Task ContentTypeHeader() { string json = "{\"Test:\"Success\"}"; await CTest <FakeServerContext> .Given(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse(json) .WithContentType("application/vnd.custom"))) .WhenAsync(i => i.MakeTheRequest("http://fake.local/123")) .ThenAsync(t => t.JsonIsReturned(json)) .And(t => t.ContentTypeIs("application/vnd.custom")) .ExecuteAsync(); }
public async Task CallingMethodOnEntityRaisesEvent() { await CTest <EntityContext <EntityClass> > .Given(a => a.EntityService()) .WhenAsync(i => i.CreateTheEntity()) .AndAsync(async i => await i.MethodIsCalledAsync(async e => await e.ArbitraryMethod())) .Then(t => t.EventIsRaised($"{typeof(EntityClass).Name}_Created")) .And(t => t.EventIsRaised($"{typeof(EntityClass).Name}_ArbitraryMethod")) .And(t => t.VersionIs(2)) .And(t => t.EventIdsMatch()) .ExecuteAsync(); }
// GET: CTest/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTest cTest = db.CTests.Find(id); if (cTest == null) { return(HttpNotFound()); } return(View(cTest)); }
// GET: CTest/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CTest cTest = db.CTests.Find(id); if (cTest == null) { return(HttpNotFound()); } // ViewBag.FCTuserID = new SelectList(db.Users, "UserID", "Forename", cTest.FCTuserID); return(View(cTest)); }
static int Main(string[] args) { //Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); CTest hTest; bool bResult; //String strMsg, strBuffer; hTest = new CTest(); hTest.Name = "FFT-Test"; if (args.Length != 0) { hTest.ArgumentCommandLineCurrentVariant = args[0];//Current Variant als argument übergeben if (args.Length > 1) { hTest.ArgumentCommandLineFFTMode = args[1];//FFTMode als argument übergeben } } bResult = hTest.Initialize(); if (!bResult || hTest.CurrentID_Menu == 0) { if (hTest.Error.Length != 0) { if (hTest.Data != null && hTest.Data.Report != null) { if (hTest.Data.Report.Error.Length == 0) { hTest.WriteLineToReport(hTest.Error); hTest.Data.Report.WriteToFileAppend(hTest.Data.Report.NameFull); } } hTest.ShowErrorInitialize(); } hTest.Deinstall(); Application.Exit(); return(1); } // Hauptfenster erstellen und ausführen Application.Run(new Honeywell.Forms.CFormMainFrame(hTest)); return(0); }
private void cg_Click(object sender, RoutedEventArgs e) { try { CTest test = (CTest)data.SelectedItem; adt = new kak(test.nb_field.ToString(), test.fio_field.ToString(), test.ph_field.ToString(), test.mt_field.ToString()); if (adt.ShowDialog() == true) { data.Items.RemoveAt(data.SelectedIndex); string sql = "UPDATE test_table SET nb_field = " + adt.nb.Text + ", fio_field = '" + adt.fio.Text + "', ph_field = " + adt.ph.Text + ", mt_field = " + adt.mt.Text + " WHERE nb_field = " + test.nb_field; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); var d = new CTest { nb_field = int.Parse(adt.nb.Text), fio_field = adt.fio.Text, ph_field = int.Parse(adt.ph.Text), mt_field = int.Parse(adt.mt.Text) }; data.Items.Add(d); } } catch (InvalidOperationException) { MessageBox.Show("Ошибка!"); } catch (FormatException) { MessageBox.Show("Неверный формат записи!"); } catch (ArgumentNullException) { MessageBox.Show("Пусто!"); } catch (OverflowException) { MessageBox.Show("Переполнение!"); } catch (NullReferenceException) { MessageBox.Show("Выберите элемент!"); } catch (SQLiteException) { MessageBox.Show("Пусто!"); } }
public async Task LambdaMatcher() { string json = "{\"Test:\"Success\"}"; string body = "{\"MatchMe:\"123\"}"; await CTest <FakeServerContext> .Given(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse("{}"))) .And(i => i.RegisterAUri(b => b.WithUri("http://fake.local/123") .WithResponse(json) .WithMethod(HttpMethod.Post) .WithContentMatch(content => content?.Equals(body) ?? false) )) .WhenAsync(i => i.MakeTheRequest("http://fake.local/123", HttpMethod.Post, body)) .ThenAsync(t => t.JsonIsReturned(json)) .ExecuteAsync(); }
private void add_Click(object sender, RoutedEventArgs e) { string db_name = "C:\\Users\\Admin\\Documents\\ри-89\\progLab4\\db.db"; SQLiteConnection m_dbConnection; m_dbConnection = new SQLiteConnection("Data Source=" + db_name + ";Version=3;"); m_dbConnection.Open(); Window1 dialog = new Window1(); if (dialog.ShowDialog() == true) { string sql = "INSERT INTO fio (fio) VALUES ('" + dialog.fio.Text + "'" + ")"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); string sql4 = "INSERT INTO rate (rateM, rateP) VALUES (" + dialog.rateM.Text + "," + dialog.rateP.Text + ")"; SQLiteCommand command4 = new SQLiteCommand(sql4, m_dbConnection); command4.ExecuteNonQuery(); string sql1 = "SELECT fio.number,fio.fio,rate.rateM,rate.rateP FROM fio,rate ORDER BY fio.number DESC"; SQLiteCommand command1 = new SQLiteCommand(sql1, m_dbConnection); SQLiteDataReader reader1 = command1.ExecuteReader(); //// while (reader.Read()) //{ reader1.Read(); //reader2.Read(); var datag = new CTest { number = int.Parse(reader1["number"].ToString()), fio = reader1["fio"].ToString(), rateM = int.Parse(reader1["rateM"].ToString()), rateP = int.Parse(reader1["rateP"].ToString()) }; data.Items.Add(datag); // } reader1.Close(); //reader2.Close(); data.Items.Refresh(); } m_dbConnection.Close(); }
public async Task CallingMethodWithAnonymousObjectRaisesEvent() { await CTest <EntityContext <EntityClass> > .Given(a => a.EntityService()) .WhenAsync(i => i.CreateTheEntity()) .AndAsync(async i => await i.MethodIsCalledAsync(async e => await e.AnonymousMethod())) .Then(t => t.EventIsRaised($"{typeof(EntityClass).Name}_Created")) .And(t => t.EventIsRaised($"{typeof(EntityClass).Name}_AnonymousMethod", q => { dynamic data = q; Assert.True(data.Data1 == "This is my data"); Assert.True(data.Data2 == 6); })) .And(t => t.VersionIs(2)) .And(t => t.EventIdsMatch()) .ExecuteAsync(); }
private void rd_Click(object sender, RoutedEventArgs e) { try { data.Items.Clear(); string sql = "SELECT * FROM test_table"; SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); SQLiteDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { var d = new CTest { nb_field = int.Parse(reader["nb_field"].ToString()), fio_field = reader["fio_field"].ToString(), ph_field = int.Parse(reader["ph_field"].ToString()), mt_field = int.Parse(reader["mt_field"].ToString()) }; data.Items.Add(d); } } catch (FormatException) { MessageBox.Show("Неверный формат записи!"); } catch (ArgumentNullException) { MessageBox.Show("Пусто!"); } catch (OverflowException) { MessageBox.Show("Переполнение!"); } catch (SQLiteException) { MessageBox.Show("Пусто!"); } } catch (Exception) { MessageBox.Show("Файл не найден!"); } }
public static void Main() { CTest CTest = new CTest(); Type t = CTest.GetType(); FieldInfo fieldTest = t.GetField("test"); CTest.test = "hello"; string test = (string)fieldTest.GetValue(CTest); Console.WriteLine(test); PropertyInfo p = t.GetProperty("test2"); CTest.test2 = "hello2"; //instruction below makes crash string test2 = (string)p.GetValue(CTest, null); Console.WriteLine(test2); Console.ReadLine(); }
private static void Test() { ITest i = new CTest(); i.Test(); }
public static int Main() { CTest t = new CTest(); if (t.f1() != 2) { Console.WriteLine("t.f1()!= 2"); return 1; } if (((ITest1)t).f1() != 1) { Console.WriteLine("((ITest1)t).f1()!=1"); return 1; } if (t.f2() != 3) { Console.WriteLine("t.f2()!=3"); return 1; } if (((IBase1)t).f3() != 10) { Console.WriteLine("((IBase1)t).f3()!= 10"); return 1; } if (((IDerived1)t).f4() != 11) { Console.WriteLine("((IDerived1)t).f4()!=11"); return 1; } if (((IDerived2)t).f5() != 12) { Console.WriteLine("((IDerived2)t).f5()!=12"); return 1; } if (t.f6() != 13) { Console.WriteLine("t.f6()!= 13"); return 1; } if (t.f7() != 15) { Console.WriteLine("t.f7()!= 15"); return 1; } if (((IBase)t).f2a != 4) { Console.WriteLine("((IBase)t).f2a!=4"); return 1; } if (((IDerived)t).f2b() != 7) { Console.WriteLine("((IDerived)t).f2b()!=7"); return 1; } if (t.f2c != 8) { Console.WriteLine("t.f2c!=8"); return 1; } if (((IDerived)t).f2a() != 5) { Console.WriteLine("((IDerived)t).f2a()!=5"); return 1; } if (t.f2b != 6) { Console.WriteLine("t.f2b!=6"); return 1; } if (((IDerived)t).f2c() != 9) { Console.WriteLine("((IDerived)t).f2c()!=9"); return 1; } C c = new C(); ITest5 ic = c; ITest5 it = t; if (c.f8() != 16) { Console.WriteLine("c.f8()!=16"); return 1; } if (t.f8() != 17) { Console.WriteLine("t.f8()!=17"); return 1; } if (ic.f8() != 16) { Console.WriteLine("ic.f8()!=16"); return 1; } if (it.f8() != 16) { Console.WriteLine("it.f8()!=16"); return 1; } if (c.f9() != 18) { Console.WriteLine("c.f9()!=18"); return 1; } if (t.f9() != 19) { Console.WriteLine("t.f9()!=19"); return 1; } if (ic.f9() != 18) { Console.WriteLine("ic.f9()!=18"); return 1; } if (it.f9() != 19) { Console.WriteLine("it.f9()!=19"); return 1; } Console.WriteLine("PASS"); return 100; }