public void All() { Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_", Database: "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")) { for (int x = 0; x < 100; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Save<ObjectClass1, int>(TempObject); } TempObject = null; IEnumerable<ObjectClass1> Objects = ORM.All<ObjectClass1>(); Assert.Equal(100, Objects.Count()); } }
public void RandomTest() { PriorityQueue<int> TestObject = new PriorityQueue<int>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); int Value=0; for (int x = 0; x < 10; ++x) { Value=Rand.Next(); TestObject.Add(x, Value); Assert.Equal(Value, TestObject.Peek()); } int HighestValue = TestObject.Peek(); for (int x = 9; x >= 0; --x) { Value = Rand.Next(); TestObject.Add(x, Value); Assert.Equal(HighestValue, TestObject.Peek()); } int Count=0; foreach(int Priority in TestObject.Keys) { foreach(int Item in TestObject[Priority]) { ++Count; } } Assert.Equal(20, Count); }
public void RandomTest() { RingBuffer<int> TestObject = new RingBuffer<int>(10); Utilities.Random.Random Rand = new Utilities.Random.Random(); int Value = 0; for (int x = 0; x < 10; ++x) { Value = Rand.Next(); TestObject.Add(Value); Assert.Equal(1, TestObject.Count); Assert.Equal(Value, TestObject.Remove()); } Assert.Equal(0, TestObject.Count); System.Collections.Generic.List<int> Values=new System.Collections.Generic.List<int>(); for (int x = 0; x < 10; ++x) { Values.Add(Rand.Next()); } TestObject.Add(Values); Assert.Equal(Values.ToArray(), TestObject.ToArray()); for (int x = 0; x < 10; ++x) { Assert.Throws<InvalidOperationException>(() => TestObject.Add(Rand.Next())); Assert.Equal(10, TestObject.Count); } }
public void RandomTest() { Entry.Priority = Random.Next(int.MinValue, int.MaxValue); Entry.URL = Random.Next <string>(new RegexStringGenerator(30)); Assert.Contains(Entry.Priority.ToString(), Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); }
public void NextName() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.Equal(3, Rand.Next <string>(new NameGenerator(false, true, true, false)).Split(' ').Length); Assert.Equal(2, Rand.Next <string>(new NameGenerator(false, false, true, false)).Split(' ').Length); Assert.Equal(4, Rand.Next <string>(new NameGenerator(true, true, true, false)).Split(' ').Length); Assert.Equal(5, Rand.Next <string>(new NameGenerator(true, true, true, true)).Split(' ').Length); }
public void RandomTest() { Entry.DefaultValue = Random.Next <string>(new RegexStringGenerator(30)); Entry.DisplayName = Random.Next <string>(new RegexStringGenerator(30)); Entry.QueryStringParam = Random.Next <string>(new RegexStringGenerator(30)); Assert.Contains(Entry.DefaultValue, Entry.ToString()); Assert.Contains(Entry.DisplayName, Entry.ToString()); Assert.Contains(Entry.QueryStringParam, Entry.ToString()); }
public void RandomTest() { Entry.Prompt = Random.Next <string>(new RegexStringGenerator(30)); Entry.Title = Random.Next <string>(new RegexStringGenerator(30)); Entry.URL = Random.Next <string>(new RegexStringGenerator(30)); Assert.Contains(Entry.Prompt, Entry.ToString()); Assert.Contains(Entry.Title, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); }
public void RandomTest() { Entry.Name = Random.Next <string>(new RegexStringGenerator(30)); Entry.URL = Random.Next <string>(new RegexStringGenerator(30)); Entry.URLDown = Random.Next <string>(new RegexStringGenerator(30)); Entry.Position = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Name, Entry.ToString()); Assert.Contains(Entry.URLDown, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.Position.ToString(), Entry.ToString()); }
public void RandomTest() { Entry.Text = Random.Next <string>(new RegexStringGenerator(30)); Entry.URL = Random.Next <string>(new RegexStringGenerator(30)); Entry.X = Random.Next(int.MinValue, int.MaxValue); Entry.Y = Random.Next(int.MinValue, int.MaxValue); Entry.Timer = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Text, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.Timer.ToString(), Entry.ToString()); Assert.Contains(Entry.X.ToString(), Entry.ToString()); Assert.Contains(Entry.Y.ToString(), Entry.ToString()); }
public void RandomTest() { Entry.Text = Random.NextString(30); Entry.URL = Random.NextString(30); Entry.X = Random.Next(int.MinValue, int.MaxValue); Entry.Y = Random.Next(int.MinValue, int.MaxValue); Entry.Timer = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Text, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.Timer.ToString(), Entry.ToString()); Assert.Contains(Entry.X.ToString(), Entry.ToString()); Assert.Contains(Entry.Y.ToString(), Entry.ToString()); }
public void RandomTest() { Entry.Prompt = Random.Next <string>(new RegexStringGenerator(30)); Entry.Title = Random.Next <string>(new RegexStringGenerator(30)); Entry.ImageURL = Random.Next <string>(new RegexStringGenerator(30)); Entry.X = Random.Next(int.MinValue, int.MaxValue); Entry.Y = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Prompt, Entry.ToString()); Assert.Contains(Entry.Title, Entry.ToString()); Assert.Contains(Entry.ImageURL, Entry.ToString()); Assert.Contains(Entry.X.ToString(), Entry.ToString()); Assert.Contains(Entry.Y.ToString(), Entry.ToString()); }
public void RandomTest() { Bag<string> BagObject = new Bag<string>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { string Value = Rand.Next<string>(new RegexStringGenerator(10)); int Count = Rand.Next(1, 10); for(int y=0;y<Count;++y) BagObject.Add(Value); Assert.Equal(Count, BagObject[Value]); } Assert.Equal(10, BagObject.Count); }
public void RandomTest() { Entry.Name = Random.NextString(30); Entry.URL = Random.NextString(30); Entry.X1 = Random.Next(int.MinValue, int.MaxValue); Entry.X2 = Random.Next(int.MinValue, int.MaxValue); Entry.Y1 = Random.Next(int.MinValue, int.MaxValue); Entry.Y2 = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Name, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.X1.ToString(), Entry.ToString()); Assert.Contains(Entry.X2.ToString(), Entry.ToString()); Assert.Contains(Entry.Y1.ToString(), Entry.ToString()); Assert.Contains(Entry.Y2.ToString(), Entry.ToString()); }
public void RandomTest() { Entry.Priority = Random.Next(int.MinValue, int.MaxValue); Entry.URL = Random.NextString(30); Assert.Contains(Entry.Priority.ToString(), Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); }
public void Any() { using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_", -1); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); string StringMaxValue = TempObject.StringMaxValue; TestObject.Save <int>(TempObject); TempObject = TestObject.Any(); Assert.Equal("Test String", TempObject.StringValue); Assert.Equal(1234.5f, TempObject.FloatValue); Assert.Equal(true, TempObject.BoolValue); Assert.Equal(12345, TempObject.LongValue); Assert.Equal(1, TempObject.ID); Assert.Equal(StringMaxValue, TempObject.StringMaxValue); } }
public void Scalar() { using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_", -1); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); for (int x = 0; x < 100; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); string StringMaxValue = TempObject.StringMaxValue; TestObject.Save <int>(TempObject); } int ASD = TestObject.Scalar <int>("SELECT COUNT(*) FROM TestTable", CommandType.Text); Assert.Equal(100, ASD); ASD = TestObject.Scalar <int>("COUNT(*)"); Assert.Equal(100, ASD); } }
public void Delete() { using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_", -1); Utilities.Random.Random Rand = new Utilities.Random.Random(); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test"; TempObject.BoolValue = false; TempObject.FloatValue = 1.5f; TempObject.LongValue = 12; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); TestObject.Save <int>(TempObject); Assert.Equal(1, TestObject.Delete(TempObject)); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT COUNT(*) AS ItemCount FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal(0, Helper.GetParameter <int>("ItemCount", -1)); } else { Assert.False(true, "Nothing was inserted"); } } } }
public void Paged() { using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); List <ObjectClass1> Objects2 = new List <ObjectClass1>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 115; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = Rand.NextString(10); TempObject.BoolValue = Rand.NextBool(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); Objects2.Add(TempObject); } TestObject.Save <int>(Objects2); IEnumerable <ObjectClass1> Objects = TestObject.Paged(); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 1); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, TestObject.PageCount()); } }
public void Delete() { Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.MicroORM.MicroORM.Map <ObjectClass1>("TestTable", "ID_") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM()) { for (int x = 0; x < 100; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.NextString(10); TempObject.BoolValue = Rand.NextBool(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Map <ObjectClass1>().Save <int>(TempObject); } TempObject = null; IEnumerable <ObjectClass1> Objects = ORM.Map <ObjectClass1>().All(); Assert.Equal(100, Objects.Count()); foreach (ObjectClass1 Object in Objects) { ORM.Map <ObjectClass1>().Delete(Object); } Objects = ORM.Map <ObjectClass1>().All(); Assert.Equal(0, Objects.Count()); } }
public void All() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")) { Mapping <ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map <ObjectClass1>("TestTable", "ID_", true, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); Helper2.Save <ObjectClass1, int>(TempObject); IEnumerable <ObjectClass1> Objects = Helper2.All <ObjectClass1>(); Assert.Equal(1, Objects.Count()); foreach (ObjectClass1 Item in Objects) { Assert.Equal("Test String", Item.StringValue); Assert.Equal(1234.5f, Item.FloatValue); Assert.Equal(true, Item.BoolValue); Assert.Equal(12345, Item.LongValue); Assert.Equal(1, Item.ID); Assert.Equal(TempObject.StringMaxValue, Item.StringMaxValue); } List <ObjectClass1> Objects2 = new List <ObjectClass1>(); Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next <string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next <bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); Objects2.Add(TempObject); } Helper2.Save <ObjectClass1, int>(Objects2); Objects = Helper2.All <ObjectClass1>(); Assert.Equal(11, Objects.Count()); } }
public void RandomTest() { Bag <string> BagObject = new Bag <string>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { string Value = Rand.Next <string>(new RegexStringGenerator(10)); int Count = Rand.Next(1, 10); for (int y = 0; y < Count; ++y) { BagObject.Add(Value); } Assert.Equal(Count, BagObject[Value]); } Assert.Equal(10, BagObject.Count); }
public void RandomTest() { ListMapping<string, int> TestObject = new ListMapping<string, int>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { string Name = Rand.Next<string>(new RegexStringGenerator(10)); for (int y = 0; y < 5; ++y) { int Value=Rand.Next(); TestObject.Add(Name, Value); Assert.Equal(y + 1, TestObject[Name].Count); Assert.Equal(Value, TestObject[Name].ElementAt(y)); } } Assert.Equal(10, TestObject.Count); }
public void Paged2() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")) { Mapping <ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map <ObjectClass1>("TestTable", "ID_", true, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); List <ObjectClass1> Objects2 = new List <ObjectClass1>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 115; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next <string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next <bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); Objects2.Add(TempObject); } Helper2.Save <ObjectClass1, int>(Objects2); IEnumerable <ObjectClass1> Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable"); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 1); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, Helper2.PageCount <ObjectClass1>("SELECT * FROM TestTable")); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 0, null, null, false, new EqualParameter <int>(50, "ID")); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 1, null, null, false, new EqualParameter <int>(50, "ID")); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand <ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 2, null, null, false, new EqualParameter <int>(50, "ID")); Assert.Equal(15, Objects.Count()); Assert.Equal(3, Helper2.PageCount <ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", 25, false, new EqualParameter <int>(50, "ID"))); } }
public void RandomTest() { ListMapping <string, int> TestObject = new ListMapping <string, int>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { string Name = Rand.Next <string>(new RegexStringGenerator(10)); for (int y = 0; y < 5; ++y) { int Value = Rand.Next(); TestObject.Add(Name, Value); Assert.Equal(y + 1, TestObject[Name].Count); Assert.Equal(Value, TestObject[Name].ElementAt(y)); } } Assert.Equal(10, TestObject.Count); }
public void RandomTest() { Entry.Name = Random.NextString(30); Entry.URL = Random.NextString(30); Entry.URLDown = Random.NextString(30); Entry.Position = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Name, Entry.ToString()); Assert.Contains(Entry.URLDown, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.Position.ToString(), Entry.ToString()); }
public void Paged() { Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.MicroORM.MicroORM.Map <ObjectClass1>("TestTable", "ID_") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM()) { for (int x = 0; x < 115; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next <string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next <bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Map <ObjectClass1>().Save <int>(TempObject); } TempObject = null; IEnumerable <ObjectClass1> Objects = ORM.Map <ObjectClass1>().Paged(); Assert.Equal(25, Objects.Count()); Objects = ORM.Map <ObjectClass1>().Paged(CurrentPage: 1); Assert.Equal(25, Objects.Count()); Objects = ORM.Map <ObjectClass1>().Paged(CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = ORM.Map <ObjectClass1>().Paged(CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = ORM.Map <ObjectClass1>().Paged(CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, ORM.Map <ObjectClass1>().PageCount()); } }
public void All() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Helper2.Save<ObjectClass1, int>(TempObject); IEnumerable<ObjectClass1> Objects = Helper2.All<ObjectClass1>(); Assert.Equal(1, Objects.Count()); foreach (ObjectClass1 Item in Objects) { Assert.Equal("Test String", Item.StringValue); Assert.Equal(1234.5f, Item.FloatValue); Assert.Equal(true, Item.BoolValue); Assert.Equal(12345, Item.LongValue); Assert.Equal(1, Item.ID); Assert.Equal(TempObject.StringMaxValue, Item.StringMaxValue); } List<ObjectClass1> Objects2 = new List<ObjectClass1>(); Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Objects2.Add(TempObject); } Helper2.Save<ObjectClass1, int>(Objects2); Objects = Helper2.All<ObjectClass1>(); Assert.Equal(11, Objects.Count()); } }
public void All() { using (Mapping <ObjectClass1> TestObject = new Mapping <ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_", -1); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.NextString(6000); TestObject.Save <int>(TempObject); IEnumerable <ObjectClass1> Objects = TestObject.All(); Assert.Equal(1, Objects.Count()); foreach (ObjectClass1 Item in Objects) { Assert.Equal("Test String", Item.StringValue); Assert.Equal(1234.5f, Item.FloatValue); Assert.Equal(true, Item.BoolValue); Assert.Equal(12345, Item.LongValue); Assert.Equal(1, Item.ID); Assert.Equal(TempObject.StringMaxValue, Item.StringMaxValue); } List <ObjectClass1> Objects2 = new List <ObjectClass1>(); Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.NextString(10); TempObject.BoolValue = Rand.NextBool(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.NextString(6000); Objects2.Add(TempObject); } TestObject.Save <int>(Objects2); Objects = TestObject.All(); Assert.Equal(11, Objects.Count()); } }
public void Update() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")) { Mapping <ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map <ObjectClass1>("TestTable", "ID_", true, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12346); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test"; TempObject.BoolValue = false; TempObject.FloatValue = 1.5f; TempObject.LongValue = 12; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); TempObject.ID = Helper2.Insert <ObjectClass1, int>(TempObject); Rand = new Utilities.Random.Random(12345); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000)); Helper2.Update(TempObject); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("Test String", Helper.GetParameter <string>("StringValue_", "")); Assert.Equal(1234.5f, Helper.GetParameter <float>("FloatValue_", 0)); Assert.Equal(true, Helper.GetParameter <bool>("BoolValue_", false)); Assert.Equal(12345, Helper.GetParameter <long>("LongValue_", 0)); Assert.Equal(TempObject.ID, Helper.GetParameter <int>("ID_", 0)); Assert.Equal(TempObject.StringMaxValue, Helper.GetParameter <string>("StringMaxValue_", "")); } else { Assert.False(true, "Nothing was inserted"); } } } }
public void RandomTest() { Entry.Name = Random.Next <string>(new RegexStringGenerator(30)); Entry.URL = Random.Next <string>(new RegexStringGenerator(30)); Entry.X1 = Random.Next(int.MinValue, int.MaxValue); Entry.X2 = Random.Next(int.MinValue, int.MaxValue); Entry.Y1 = Random.Next(int.MinValue, int.MaxValue); Entry.Y2 = Random.Next(int.MinValue, int.MaxValue); Assert.Contains(Entry.Name, Entry.ToString()); Assert.Contains(Entry.URL, Entry.ToString()); Assert.Contains(Entry.X1.ToString(), Entry.ToString()); Assert.Contains(Entry.X2.ToString(), Entry.ToString()); Assert.Contains(Entry.Y1.ToString(), Entry.ToString()); Assert.Contains(Entry.Y2.ToString(), Entry.ToString()); }
public void Delete() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("","Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false",CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test"; TempObject.BoolValue = false; TempObject.FloatValue = 1.5f; TempObject.LongValue = 12; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Helper2.Save<ObjectClass1, int>(TempObject); Assert.Equal(1, Helper2.Delete<ObjectClass1>(TempObject)); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT COUNT(*) AS ItemCount FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal(0, Helper.GetParameter<int>("ItemCount", -1)); } else { Assert.False(true,"Nothing was inserted"); } } } }
public void Paged2() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); List<ObjectClass1> Objects2 = new List<ObjectClass1>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 115; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Objects2.Add(TempObject); } Helper2.Save<ObjectClass1, int>(Objects2); IEnumerable<ObjectClass1> Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable"); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 1); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable", CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, Helper2.PageCount<ObjectClass1>("SELECT * FROM TestTable")); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 0, null, null, false, new EqualParameter<int>(50, "ID")); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 1, null, null, false, new EqualParameter<int>(50, "ID")); Assert.Equal(25, Objects.Count()); Objects = Helper2.PagedCommand<ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", "", 25, 2, null, null, false, new EqualParameter<int>(50, "ID")); Assert.Equal(15, Objects.Count()); Assert.Equal(3, Helper2.PageCount<ObjectClass1>("SELECT * FROM TestTable WHERE ID_>@ID", 25, false, new EqualParameter<int>(50, "ID"))); } }
public void All() { using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TestObject.Save<int>(TempObject); IEnumerable<ObjectClass1> Objects = TestObject.All(); Assert.Equal(1, Objects.Count()); foreach (ObjectClass1 Item in Objects) { Assert.Equal("Test String", Item.StringValue); Assert.Equal(1234.5f, Item.FloatValue); Assert.Equal(true, Item.BoolValue); Assert.Equal(12345, Item.LongValue); Assert.Equal(1, Item.ID); } List<ObjectClass1> Objects2 = new List<ObjectClass1>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 10; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.NextString(10); TempObject.BoolValue = Rand.NextBool(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); Objects2.Add(TempObject); } TestObject.Save<int>(Objects2); Objects = TestObject.All(); Assert.Equal(11, Objects.Count()); } }
public void Any() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); string StringMaxValue = TempObject.StringMaxValue; Helper2.Save<ObjectClass1, int>(TempObject); TempObject = Helper2.Any<ObjectClass1>(); Assert.Equal("Test String", TempObject.StringValue); Assert.Equal(1234.5f, TempObject.FloatValue); Assert.Equal(true, TempObject.BoolValue); Assert.Equal(12345, TempObject.LongValue); Assert.Equal(1, TempObject.ID); Assert.Equal(StringMaxValue, TempObject.StringMaxValue); } }
public void NextLoremIpsumTest() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.NotNull(Rand.Next<string>(new LoremIpsumGenerator(1, 4))); }
public void NextStringTest() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.Equal(10, Rand.Next <string>(new RegexStringGenerator(10)).Length); }
public void RegisterGenerator() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Rand.RegisterGenerator <string>(new NameGenerator()); Assert.True(100.Times(x => Rand.Next <string>()).All(x => x.Split(' ').Length == 2)); }
public void NextStringTest2() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.True(Regex.IsMatch(Rand.Next <string>(new PatternGenerator("(###)###-####")), @"\(\d{3}\)\d{3}-\d{4}")); Assert.True(Regex.IsMatch(Rand.Next <string>(new PatternGenerator("(@@@)###-####")), @"\([a-zA-Z]{3}\)\d{3}-\d{4}")); }
public void RegisterGenerator() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.DoesNotThrow<Exception>(() => Rand.RegisterGenerator<string>(new NameGenerator())); Assert.True(100.Times(x => Rand.Next<string>()).TrueForAll(x => x.Split(' ').Length == 2)); }
public void NextLoremIpsumTest() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.NotNull(Rand.Next <string>(new LoremIpsumGenerator(1, 4))); }
public void NextStringTest2() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.True(Regex.IsMatch(Rand.Next<string>(new PatternGenerator("(###)###-####")), @"\(\d{3}\)\d{3}-\d{4}")); Assert.True(Regex.IsMatch(Rand.Next<string>(new PatternGenerator("(@@@)###-####")), @"\([a-zA-Z]{3}\)\d{3}-\d{4}")); }
public void NextStringTest() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.Equal(10, Rand.Next<string>(new RegexStringGenerator(10)).Length); }
public void NextName() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Assert.Equal(3, Rand.Next<string>(new NameGenerator(false, true, true, false)).Split(' ').Length); Assert.Equal(2, Rand.Next<string>(new NameGenerator(false, false, true, false)).Split(' ').Length); Assert.Equal(4, Rand.Next<string>(new NameGenerator(true, true, true, false)).Split(' ').Length); Assert.Equal(5, Rand.Next<string>(new NameGenerator(true, true, true, true)).Split(' ').Length); }
public void Scalar() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12345); for (int x = 0; x < 100; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); string StringMaxValue = TempObject.StringMaxValue; Helper2.Save<ObjectClass1, int>(TempObject); } int ASD = Helper2.Scalar<ObjectClass1, int>("SELECT COUNT(*) FROM TestTable", CommandType.Text); Assert.Equal(100, ASD); ASD = Helper2.Scalar<ObjectClass1, int>("COUNT(*)"); Assert.Equal(100, ASD); } }
public void Paged() { Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.MicroORM.MicroORM.Map<ObjectClass1>("TestTable", "ID_") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM()) { for (int x = 0; x < 115; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Map<ObjectClass1>().Save<int>(TempObject); } TempObject = null; IEnumerable<ObjectClass1> Objects = ORM.Map<ObjectClass1>().Paged(); Assert.Equal(25, Objects.Count()); Objects = ORM.Map<ObjectClass1>().Paged(CurrentPage: 1); Assert.Equal(25, Objects.Count()); Objects = ORM.Map<ObjectClass1>().Paged(CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = ORM.Map<ObjectClass1>().Paged(CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = ORM.Map<ObjectClass1>().Paged(CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, ORM.Map<ObjectClass1>().PageCount()); } }
public void Update() { using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_"); TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_") .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_"); Utilities.Random.Random Rand = new Utilities.Random.Random(12346); ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = "Test"; TempObject.BoolValue = false; TempObject.FloatValue = 1.5f; TempObject.LongValue = 12; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); TempObject.ID = Helper2.Insert<ObjectClass1, int>(TempObject); Rand = new Utilities.Random.Random(12345); TempObject.StringValue = "Test String"; TempObject.BoolValue = true; TempObject.FloatValue = 1234.5f; TempObject.LongValue = 12345; TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Helper2.Update(TempObject); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM TestTable", "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("Test String", Helper.GetParameter<string>("StringValue_", "")); Assert.Equal(1234.5f, Helper.GetParameter<float>("FloatValue_", 0)); Assert.Equal(true, Helper.GetParameter<bool>("BoolValue_", false)); Assert.Equal(12345, Helper.GetParameter<long>("LongValue_", 0)); Assert.Equal(TempObject.ID, Helper.GetParameter<int>("ID_", 0)); Assert.Equal(TempObject.StringMaxValue, Helper.GetParameter<string>("StringMaxValue_", "")); } else { Assert.False(true,"Nothing was inserted"); } } } }
public void Paged() { using (Mapping<ObjectClass1> TestObject = new Mapping<ObjectClass1>("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false", "TestTable", "ID_")) { TestObject.Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_") .Map(x => x.StringMaxValue, "StringMaxValue_", -1); List<ObjectClass1> Objects2 = new List<ObjectClass1>(); Utilities.Random.Random Rand = new Utilities.Random.Random(); for (int x = 0; x < 115; ++x) { ObjectClass1 TempObject = new ObjectClass1(); TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10)); TempObject.BoolValue = Rand.Next<bool>(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(0, 100); TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000)); Objects2.Add(TempObject); } TestObject.Save<int>(Objects2); IEnumerable<ObjectClass1> Objects = TestObject.Paged(); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage:1); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 2); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 3); Assert.Equal(25, Objects.Count()); Objects = TestObject.Paged(CurrentPage: 4); Assert.Equal(15, Objects.Count()); Assert.Equal(5, TestObject.PageCount()); } }
public void Delete() { Utilities.SQL.MicroORM.MicroORM.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"); Utilities.SQL.MicroORM.MicroORM.Map<ObjectClass1>("TestTable", "ID_") .Map(x => x.ID, "ID_") .Map(x => x.StringValue, "StringValue_", 100) .Map(x => x.FloatValue, "FloatValue_") .Map(x => x.BoolValue, "BoolValue_") .Map(x => x.LongValue, "LongValue_"); ObjectClass1 TempObject = null; Utilities.Random.Random Rand = new Utilities.Random.Random(); using (Utilities.SQL.MicroORM.MicroORM ORM = new Utilities.SQL.MicroORM.MicroORM()) { for (int x = 0; x < 100; ++x) { TempObject = new ObjectClass1(); TempObject.StringValue = Rand.NextString(10); TempObject.BoolValue = Rand.NextBool(); TempObject.FloatValue = (float)Rand.NextDouble(); TempObject.LongValue = Rand.Next(); ORM.Map<ObjectClass1>().Save<int>(TempObject); } TempObject = null; IEnumerable<ObjectClass1> Objects = ORM.Map<ObjectClass1>().All(); Assert.Equal(100, Objects.Count()); foreach (ObjectClass1 Object in Objects) { ORM.Map<ObjectClass1>().Delete(Object); } Objects = ORM.Map<ObjectClass1>().All(); Assert.Equal(0, Objects.Count()); } }
public void RegisterGenerator() { Utilities.Random.Random Rand = new Utilities.Random.Random(); Rand.RegisterGenerator<string>(new NameGenerator()); Assert.True(100.Times(x => Rand.Next<string>()).All(x => x.Split(' ').Length == 2)); }