Example #1
0
        public void TestAssertExist ()
        {
            Simple simple= new Simple();
            simple.AssertExists();
            simple=default(Simple);
            try{
                simple.AssertExists();
                Assert.Fail("Fail");
            }
            catch{
                Console.WriteLine("first pass");
            }


            simple=null;
            try{
                simple.AssertExists();
                Assert.Fail("Fail");
            }
            catch{

                Console.WriteLine("second pass");
            }

        }
 /// <summary>
 /// Method executed before real method execution. If ReturnValue is set, the real method body is not executed.
 /// </summary>
 /// <param name="method"></param>
 public override sealed void MethodEnter(Simple.MethodContext method)
 {
     string key = GetKey(method);
     method["Cache.Key"] = key;
     method.ReturnValue = this.GetObject(method, key);
     method["Cache.Hit"] = method.ReturnValue != null;
 }
 public void ValueTest()
 {
     var foo = new Simple();
     foo.Value = 100;
     var value = foo.Value;
     Assert.True(100 == value);
 }
Example #4
0
        public void SimpleTests()
        {
            dynamic simple = new Simple();

            simple.foo = "hello dynamic";

            Assert.AreEqual(simple.foo, "hello dynamic");
        }
Example #5
0
 public void ShouldNotThrowUserExceptionOnInsert()
 {
     using (var container = new RhetosTestContainer())
     {
         var repository = container.Resolve<Common.DomRepository>();
         var entity = new Simple { StringFrom200To249 = "205" };
         repository.TestRegex.Simple.Insert(new[] { entity });
     }
 }
Example #6
0
 public void EmptyValuesAreAllowed()
 {
     using (var executionContext = new CommonTestExecutionContext())
     {
         var repository = new Common.DomRepository(executionContext);
         var entity = new Simple { StringFrom200To249 = null };
         repository.TestRegex.Simple.Insert(new[] { entity });
     }
 }
Example #7
0
 public void EmptyValuesAreAllowed()
 {
     using (var container = new RhetosTestContainer())
     {
         var repository = container.Resolve<Common.DomRepository>();
         var entity = new Simple { StringFrom200To249 = null };
         repository.TestRegex.Simple.Insert(new[] { entity });
     }
 }
Example #8
0
        public void TestMethod1()
        {
            var x = new Simple() { Name = "Pasta", Value = 5 };
            
            var q = new Simple[] { x,x,x,x,x,x,x,x};
            var bytes = Bson.Serializer.Serialize(q);

            var z = Bson.Deserializer.Deserialize<Simple[]>(bytes);
        }
Example #9
0
 public void Uint()
 {
     using (var session = sessionFactory.OpenSession()) {
         using (var tx = session.BeginTransaction()) {
             var s = new Simple {Number = 5};
             session.Save(s);
             tx.Commit();
         }
     }
 }
Example #10
0
 public void ShouldThowUserExceptionOnInsert()
 {
     using (var container = new RhetosTestContainer())
     {
         var repository = container.Resolve<Common.DomRepository>();
         var entity = new Simple { StringFrom200To249 = "." };
         TestUtility.ShouldFail<Rhetos.UserException>(
             () => repository.TestRegex.Simple.Insert(new[] { entity }),
             "StringFrom200To249 must be between 200 and 249", "Property:StringFrom200To249");
     }
 }
Example #11
0
        public bool CompileAndRun(Simple.Data.Database database, out object output)
        {
            var code = MakeCode();
            var compiled = Compile(code);

            if (compiled.Errors.HasErrors)
            {
                output = ReturnErrors(compiled);
                return false;
            }
            output = ReturnOutput(compiled, database);
            return true;
        }
Example #12
0
 internal InitialI(Ice.ObjectAdapter adapter)
 {
     _simple = new Simple();
     _simple.message = "a message 4 u";
     
     _printer = new PrinterI();
     _printer.message = "Ice rulez!";
     _printerProxy = PrinterPrxHelper.uncheckedCast(adapter.addWithUUID(_printer));
     
     _derivedPrinter = new DerivedPrinterI();
     _derivedPrinter.message = _printer.message;
     _derivedPrinter.derivedMessage = "a derived message 4 u";
     adapter.addWithUUID(_derivedPrinter);
 }
Example #13
0
        public void DefaultErrorMessageTest()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();
                var entity = new Simple { DefaultErrorMessageTest = "123" };
                repository.TestRegex.Simple.Insert(new[] { entity });

                entity.DefaultErrorMessageTest = "x";
                TestUtility.ShouldFail<Rhetos.UserException>(
                    () => repository.TestRegex.Simple.Update(new[] { entity }),
                    "Property DefaultErrorMessageTest does not match required format.", "Property:DefaultErrorMessageTest");
            }
        }
Example #14
0
        public void DefaultErrorMessageTest()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);
                var entity = new Simple { DefaultErrorMessageTest = "123" };
                repository.TestRegex.Simple.Insert(new[] { entity });

                entity.DefaultErrorMessageTest = "x";
                TestUtility.ShouldFail(
                    () => repository.TestRegex.Simple.Update(new[] { entity }),
                    "UserException", "Property DefaultErrorMessageTest does not match required format.", "Property:DefaultErrorMessageTest");
            }
        }
Example #15
0
    static void Main()
    {
        // ----- Object creation -----
        Console.WriteLine( "Hello testplswigsimp in C#." );

        Simple a = new Simple("");
        Console.WriteLine( "Created a object of Simple: " + a.valid() + ", " + a);

        Simple2 b = new Simple2(a.p());
        Console.WriteLine( "Converted a interface: " + (b.valid() ? "ok, " : " fail, ") + b);

        // ----- Call some methods -----

        Console.WriteLine( "Simple.add(1, 2) = " + a.add(1, 2) );

        Console.WriteLine( "Goodbye" );
    }
Example #16
0
        public void SimpleTest2()
        {
            var item = new Simple();

            using (IDocumentStore store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Store(item);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var stored = session.Load<Simple>("simples/1");
                    Assert.NotNull(stored);
                    Assert.Equal("simples/1", stored.Id);
                }
            }
        }
Example #17
0
        static void Main(string[] args)
        {
            Lomito lomo1 = new BaseLomito();

            lomo1 = new PapasFritas(lomo1);
            lomo1 = new Simple(lomo1);

            Lomito lomo2 = new BaseLomito();

            lomo2 = new Vegetariano(lomo2);

            Lomito lomo3 = new BaseLomito();

            lomo3 = new Completo(lomo3);

            Lomito lomo4 = new BaseLomito();

            lomo4 = new Macho(lomo4);

            Lomito lomo5 = new BaseLomito();

            lomo5 = new Macho(lomo5);
            lomo5 = new PapasFritas(lomo5);
            lomo5 = new Simple(lomo5);
            lomo5 = new Completo(lomo5);

            var precio1 = lomo1.precio();
            var precio2 = lomo2.precio();
            var precio3 = lomo3.precio();
            var precio4 = lomo4.precio();
            var precio5 = lomo5.precio();

            string cadena = "El lomo ";

            Console.WriteLine(cadena + "simple con papas cuesta: " + precio1);
            Console.WriteLine(cadena + "vegetariano cuesta: " + precio2);
            Console.WriteLine(cadena + "completo cuesta: " + precio3);
            Console.WriteLine(cadena + "macho cuesta: " + precio4);
            Console.WriteLine("EL combo reventar cuesta: " + precio5);
            Console.ReadLine();
        }
        public void TwoOutOfThree()
        {
            var something =
                new SomethingToShrink
            {
                PropertyOne   = 42,
                PropertyTwo   = 42,
                PropertyThree = 42,
            };
            var composite =
                new ShrinkingStrategy()
                .Add(Simple.AllValues())
                .RegisterAll(something);

            composite.Shrink(() => something.PropertyOne == 42 && something.PropertyTwo == 42);

            Assert.False(composite.Shrunk());
            Assert.False(composite.Shrunk(something, e => e.PropertyOne));
            Assert.False(composite.Shrunk(something, e => e.PropertyTwo));
            Assert.True(composite.Shrunk(something, e => e.PropertyThree));
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AddressUType != null)
         {
             hashCode = hashCode * 59 + AddressUType.GetHashCode();
         }
         if (Simple != null)
         {
             hashCode = hashCode * 59 + Simple.GetHashCode();
         }
         if (Paf != null)
         {
             hashCode = hashCode * 59 + Paf.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #20
0
        private static void Main(string[] args)
        {
            Console.WriteLine("Simple with reader");
            SimpleWithReader simpleWithReader = SimpleWithReader.Load("source\\simple.json");

            Console.WriteLine($"string: {simpleWithReader.StringProperty}");
            Console.WriteLine($"number: {simpleWithReader.NumberProperty}");
            Console.WriteLine($"boolean: {simpleWithReader.BooleanProperty}");

            Console.WriteLine();
            Console.WriteLine("Simple with extern reader");
            Simple simple = SimpleReader.Load("source\\simple.json");

            Console.WriteLine($"string: {simple.StringProperty}");
            Console.WriteLine($"number: {simple.NumberProperty}");
            Console.WriteLine($"boolean: {simple.BooleanProperty}");

            Console.WriteLine();
            Console.WriteLine("Press key to EXIT...");
            Console.ReadKey();
        }
Example #21
0
        static void Main(string[] args)
        {
            //var result = MyHelper.GetSurname("Aijaz");

            //   var result = "Saif".GetSurname("Maher");

            // Console.WriteLine(result);

            //var result = "Saif".IsActive();
            //Console.WriteLine(result);

            var obj = new Simple("Aijaz Ali", 30);

            var obj2 = new Simple("Saif", 12);

            Console.WriteLine(obj2.Name);

            Console.WriteLine(obj2.Age);

            Console.ReadKey();
        }
Example #22
0
        static double StructSimple_0()
        {
            double result = 0;

            Data d;

            d.LastValue = 115;

            Simple s = new Simple();

            s.Position  = 1;
            s.Exists    = false;
            s.LastValue = 5.5;
            s.X         = 20;

            result += s.Position + s.LastValue + s.X;
            s.X     = 4;
            result += s.X + d.LastValue;

            return(result);
        }
Example #23
0
        public void Concurrency_Passing_Test2()
        {
            using (var store = NewRemoteDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    session.Advanced.UseOptimisticConcurrency = true;
                    Simple simple = new Simple { Id = 1, key = "New", stamp = (int)DateTime.UtcNow.Ticks };
                    session.Store(simple);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    session.Advanced.UseOptimisticConcurrency = false;
                    Simple simple = new Simple { Id = 1, key = "Override", stamp = (int)DateTime.UtcNow.Ticks };
                    session.Store(simple);
                    session.SaveChanges();
                }
            }
        }
Example #24
0
        public Interes MapearInteres(string linea)
        {
            Interes interes;

            string[] datos         = linea.Split(';');
            string   tipo          = datos[4];
            int      tiempo        = Convert.ToInt32(datos[5]);
            double   tasa          = Convert.ToDouble(datos[6]) * 100;
            double   valorPrestado = Convert.ToDouble(datos[7]);

            if (EsCompuesto(datos[4]))
            {
                interes = new Compuesto(valorPrestado, tiempo, tasa);
            }
            else
            {
                interes = new Simple(valorPrestado, tiempo, tasa);
            }
            interes.CalcularValorTotal();
            return(interes);
        }
 public void SetParameterListWithDictionary()
 {
     using (var s = OpenSession())
         using (var t = s.BeginTransaction())
         {
             var simple = new Simple {
                 Name = "Simple 1"
             };
             s.Save(simple, 10L);
             var q          = s.CreateQuery("from s in class Simple where s.Name in (:Name)");
             var parameters = new Dictionary <string, object>
             {
                 { nameof(simple.Name), new [] { simple.Name } }
             };
             q.SetProperties(parameters);
             var results = q.List();
             Assert.That(results, Has.One.EqualTo(simple));
             s.Delete(simple);
             t.Commit();
         }
 }
Example #26
0
        private async Task DBFiles_BTree_Test_UpdateObjects(int c)
        {
            Simple[] Objects = new Simple[c];
            Simple   Obj;
            int      i;

            for (i = 0; i < c; i++)
            {
                Objects[i] = Obj = CreateSimple(this.MaxStringLength);
                await this.file.SaveNewObject(Obj);
            }

            //await AssertConsistent(this.file, this.provider, null, null, true);
            //Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeBeforeUpdates.xml"));

            for (i = 0; i < c; i++)
            {
                Obj          = CreateSimple(this.MaxStringLength);
                Obj.ObjectId = Objects[i].ObjectId;

                await this.file.UpdateObject(Obj);

                Objects[i] = Obj;

                Obj = await this.file.LoadObject <Simple>(Obj.ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj);
            }

            await AssertConsistent(this.file, this.provider, null, null, true);

            //Console.Out.WriteLine(await ExportXML(this.file, "Data\\BTreeAfterUpdates.xml"));

            for (i = 0; i < c; i++)
            {
                Obj = await this.file.LoadObject <Simple>(Objects[i].ObjectId);

                DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj);
            }
        }
Example #27
0
        private void AddTool()
        {
            if (_mainTool.InvokeRequired)
            {
                var s = new Simple(AddTool);
                _mainTool.Invoke(s, null);
            }
            else
            {
                _tsmiSystem.Text                    = "系统(&S)";
                _tsmiDbSet.Text                     = _tsbDbSet.Text = "数据库配置";
                _tsmiDbConfig.DisplayStyle          = _tsbDbSet.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                _tsbDbSet.Click                    += tsbDBSet_Click;
                _tsmiDbSet.Click                   += tsbDBSet_Click;
                _tsmiDbSet.Image                    = _tsbDbSet.Image = Resources.dbConfig;
                _tscbDbConfig.DropDownStyle         = ComboBoxStyle.DropDownList;
                _tscbDbConfig.DisplayStyle          = ToolStripItemDisplayStyle.ImageAndText;
                _tscbDbConfig.SelectedIndexChanged += TscbDbConfigSelectedIndexChanged;

                _tsmiDbConfig.Text         = _tsbDbReSet.Text = "重新加载数据库";
                _tsmiDbConfig.DisplayStyle = _tsbDbReSet.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                _tsbDbReSet.Click         += TsbDbReSetClick;
                _tsmiDbConfig.Click       += TsbDbReSetClick;
                _tsmiDbConfig.Image        = _tsbDbReSet.Image = Resources.reload;
                _tsmiExit.Text             = "退出(&X)";
                _tsmiExit.DisplayStyle     = ToolStripItemDisplayStyle.ImageAndText;
                _tsmiExit.Image            = Resources.exit;
                _tsmiExit.Click           += new EventHandler(_tsmiExit_Click);
                _tsmiSystem.DropDownItems.Add(_tsmiDbSet);
                _tsmiSystem.DropDownItems.Add(_tsmiDbConfig);
                _tsmiSystem.DropDownItems.Add(_tsmiSeparator);
                _tsmiSystem.DropDownItems.Add(_tsmiExit);
                Application.MainMenu.Items.Insert(0, _tsmiSystem);

                Application.MainTool.Items.Insert(0, _tsbDbSet);
                Application.MainTool.Items.Insert(1, _tscbDbConfig);
                Application.MainTool.Items.Insert(2, _tsbDbReSet);
                Application.MainTool.Items.Insert(3, _toolStripSeparator);
            }
        }
Example #28
0
        public void TestTrackableCollection_RemoveAt(bool track)
        {
            var acc  = new Accumulator("test");
            var b    = new Simple("b");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), b, new Simple("c")
            };

            coll.RemoveAt(1);
            Assert.AreEqual(2, coll.Count);
            Assert.AreEqual("c", coll[1].Value);

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
Example #29
0
    static void Main()
    {
        // ----- Object creation -----
        Console.WriteLine("Hello testplsimple in C#.");

        Simple a = new Simple("");

        Console.WriteLine("Created a object of Simple: " + a.valid() + ", " + a);

        Simple2 b = new Simple2(a.p());

        Console.WriteLine("Converted a interface: " + (b.valid() ? "ok, " : " fail, ") + b);

        // ----- Call some methods -----

        if (a.valid())
        {
            Console.WriteLine("Simple.add(1, 2) = " + a.add(1, 2));
        }

        Console.WriteLine("Goodbye");
    }
Example #30
0
 private void Button14_Click(object sender, EventArgs e)
 {
     Location = Simple.SingleLocation(EdgeLocationType.TopLeft, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.TopCenter, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.TopRight, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.BotLeft, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.BotCenter, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.BotRight, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.LeftCenter, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.RightCenter, Width, Height, 32);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.CalcCenter, Width, Height);
     Thread.Sleep(750);
     Location = Simple.SingleLocation(EdgeLocationType.FullCenter, Width, Height);
 }
Example #31
0
 protected void AddContextMenu()
 {
     if (Application.MainContextMenu.InvokeRequired)
     {
         var s = new Simple(AddContextMenu);
         Application.MainContextMenu.Invoke(s, null);
     }
     else
     {
         foreach (ToolStripMenuItem v in Application.MainMenu.Items)
         {
             if (v.Text == "工具(&T)")
             {
                 v.DropDownItems.Add(_tsiGen);
                 _tsiGen.Text         = "事件监听";
                 _tsiGen.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                 _tsiGen.Click       += new EventHandler(_tsiGen_Click);
                 break;
             }
         }
     }
 }
Example #32
0
 protected void AddTool()
 {
     if (Application.MainMenu.InvokeRequired)
     {
         var s = new Simple(AddTool);
         Application.MainMenu.Invoke(s, null);
     }
     else
     {
         foreach (ToolStripMenuItem v in Application.MainMenu.Items)
         {
             if (v.Text == "工具(&T)")
             {
                 v.DropDownItems.Add(_tsbDownload);
                 _tsbDownload.Text         = "阿里云";
                 _tsbDownload.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
                 _tsbDownload.Click       += new EventHandler(_tsbDownload_Click);
                 break;
             }
         }
     }
 }
 public void SetNullParameterWithDictionary()
 {
     using (var s = OpenSession())
         using (var t = s.BeginTransaction())
         {
             var simple = new Simple {
                 Name = "Simple 1"
             };
             s.Save(simple, 10L);
             var q          = s.CreateQuery("from s in class Simple where s.Name = :Name and (s.Address = :Address or :Address is null and s.Address is null)");
             var parameters = new Dictionary <string, object>
             {
                 { nameof(simple.Name), simple.Name },
                 { nameof(simple.Address), null },
             };
             q.SetProperties(parameters);
             var results = q.List();
             Assert.That(results, Has.One.EqualTo(simple));
             s.Delete(simple);
             t.Commit();
         }
 }
Example #34
0
        /// <summary>
        /// Posts a message to a set of given jira tickets as a comment
        /// </summary>
        /// <param name="credentials">Users jira credentials</param>
        /// <param name="message">Message to be posted as a comment</param>
        /// <param name="ticketId">Jira ticket ID to post comment on, can be multiple comma seperated ticket ids</param>
        /// <returns>bool indicating success of posting a comment.</returns>
        public async static Task <bool> PostMessageToJiraTicket(Simple credentials, string message, string ticketId)
        {
            Atlassian.Jira.Jira jiraInstance = GetJiraInstance(credentials);

            var tickets = ticketId.Split(',').Select(x => x.Trim()).ToArray();

            foreach (var ticket in tickets)
            {
                try
                {
                    var issueTask = await jiraInstance.Issues.GetIssueAsync(ticket);

                    await issueTask.AddCommentAsync(message);
                }
                catch (Exception e)
                {
                    string exceptionMessage = string.Format("Unable to post log message to jira ticket '{0}'\n\n{1}", ticket, e.InnerException.Message);
                    throw new InvalidOperationException(exceptionMessage);
                }
            }
            return(true);
        }
Example #35
0
        //
        // Validates if a set of Jira tickets exists
        // where ticketId is a comma seperated list of jira tickets ids
        public async static Task <bool> ValidateJiraTicker(Simple credentials, string ticketId)
        {
            // Create our rest client
            Atlassian.Jira.Jira jiraInstance = GetJiraInstance(credentials);

            var tickets = ticketId.Split(',').Select(x => x.Trim()).ToArray();

            foreach (var ticket in tickets)
            {
                try
                {
                    var issueTask = await jiraInstance.Issues.GetIssueAsync(ticket);
                }
                catch (Exception e)
                {
                    string message = string.Format("Unable to find Jira ticket '{0}'\n\n{1}", ticket, e.InnerException.Message);
                    throw new InvalidOperationException(message);
                }
            }
            // We found it just fine
            return(true);
        }
Example #36
0
        public async Task QueryCacheWithNullParametersAsync()
        {
            Simple simple = new Simple();

            using (ISession s = OpenSession())
            {
                await(s.SaveAsync(simple, 1L));
                await(s.FlushAsync());
            }

            using (ISession s = OpenSession())
            {
                await(s
                      .CreateQuery("from Simple s where s = :s or s.Name = :name or s.Address = :address")
                      .SetEntity("s", await(s.LoadAsync(typeof(Simple), 1L)))
                      .SetString("name", null)
                      .SetString("address", null)
                      .SetCacheable(true)
                      .UniqueResultAsync());

                // Run a second time, just to test the query cache
                object result = await(s
                                      .CreateQuery("from Simple s where s = :s or s.Name = :name or s.Address = :address")
                                      .SetEntity("s", await(s.LoadAsync(typeof(Simple), 1L)))
                                      .SetString("name", null)
                                      .SetString("address", null)
                                      .SetCacheable(true)
                                      .UniqueResultAsync());

                Assert.IsNotNull(result);
                Assert.AreEqual(1L, (long)s.GetIdentifier(result));
            }

            using (ISession s = OpenSession())
            {
                await(s.DeleteAsync("from Simple"));
                await(s.FlushAsync());
            }
        }
Example #37
0
        protected override void AddContextMenu()
        {
            if (Application.MainContextMenu.InvokeRequired)
            {
                var s = new Simple(AddContextMenu);
                Application.MainContextMenu.Invoke(s, null);
            }
            else
            {
                base.AddContextMenu();
                _tsiGen.Text             = "Java代码生成";
                _tsibsGen.Text           = "BS代码生成";
                _tsiwsGen.Text           = "WS代码生成";
                _tsispringConfigGen.Text = "Spring配置生成";
                _tsiGen.Enabled          = false;

                _tsiGen.DropDownItems.AddRange(new[] { _tsibsGen, _tsiwsGen, _tsispringConfigGen });
                _tsibsGen.Click           += (_tsibsGen_Click);
                _tsiwsGen.Click           += (_tsiwsGen_Click);
                _tsispringConfigGen.Click += (_tsispringConfigGen_Click);
            }
        }
Example #38
0
        public void RequestBytes_Selector_SendsSelectorValue()
        {
            var tcp    = new Simple(tcpClient);
            var stream = new MemoryStream();

            tcpClient.Connected.Returns(true);
            tcpClient.GetStream().Returns <Stream>(stream);

            tcp.Open("", 0);
            tcp.RequestBytes("info");

            tcpClient.Received(1).GetStream();

            byte[] data = new byte[stream.Length];

            stream.Position = 0;
            stream.Read(data, 0, data.Length);

            var result = new string(Encoding.ASCII.GetChars(data));

            Assert.AreEqual("info", result);
        }
    public static int test_3_return_struct()
    {
        Simple v = get_simple(1);

        if (v.a != 1)
        {
            return(0);
        }
        if (v.b != 2)
        {
            return(0);
        }
        if (v.c != 3)
        {
            return(0);
        }
        if (v.d != 4)
        {
            return(0);
        }
        return(3);
    }
 public async Task SetParametersWithHashtableAsync()
 {
     using (var s = OpenSession())
         using (var t = s.BeginTransaction())
         {
             var simple = new Simple {
                 Name = "Simple 1"
             };
             await(s.SaveAsync(simple, 10L));
             var q          = s.CreateQuery("from s in class Simple where s.Name = :Name and (s.Address = :Address or :Address is null and s.Address is null)");
             var parameters = new Hashtable
             {
                 { nameof(simple.Name), simple.Name },
                 { nameof(simple.Address), simple.Address },
             };
             q.SetProperties(parameters);
             var results = await(q.ListAsync());
             Assert.That(results, Has.One.EqualTo(simple));
             await(s.DeleteAsync(simple));
             await(t.CommitAsync());
         }
 }
 public async Task SetParametersWithDictionaryAsync()
 {
     using (var s = OpenSession())
         using (var t = s.BeginTransaction())
         {
             var simple = new Simple {
                 Name = "Simple 1"
             };
             await(s.SaveAsync(simple, 10L));
             var q          = s.CreateQuery("from s in class Simple where s.Name = :Name and s.Count = :Count");
             var parameters = new Dictionary <string, object>
             {
                 { nameof(simple.Name), simple.Name },
                 { nameof(simple.Count), simple.Count },
             };
             q.SetProperties(parameters);
             var results = await(q.ListAsync());
             Assert.That(results, Has.One.EqualTo(simple));
             await(s.DeleteAsync(simple));
             await(t.CommitAsync());
         }
 }
Example #42
0
        public async Task SetPropertiesOnQueryAsync()
        {
            DateTime now = DateTime.Now;

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            // create a new
            long   key    = 10;
            Simple simple = new Simple();

            simple.Name    = "Simple 1";
            simple.Address = "Street 12";
            simple.Date    = now;
            simple.Count   = 99;

            await(s.SaveAsync(simple, key));

            await(t.CommitAsync());

            t = s.BeginTransaction();

            IQuery q = s.CreateQuery("from s in class Simple where s.Name=:Name and s.Count=:Count");

            q.SetProperties(simple);

            Simple loadedSimple = (Simple)(await(q.ListAsync()))[0];

            Assert.AreEqual(99, loadedSimple.Count);
            Assert.AreEqual("Simple 1", loadedSimple.Name);
            Assert.AreEqual("Street 12", loadedSimple.Address);
            Assert.AreEqual(now.ToString(), loadedSimple.Date.ToString());

            await(s.DeleteAsync(simple));

            await(t.CommitAsync());
            s.Close();
        }
    public static int test_2_return_struct_virtual()
    {
        Tests  t = new Tests();
        Simple v = t.v_get_simple(2);

        if (v.a != 2)
        {
            return(0);
        }
        if (v.b != 3)
        {
            return(0);
        }
        if (v.c != 4)
        {
            return(0);
        }
        if (v.d != 5)
        {
            return(0);
        }
        return(2);
    }
Example #44
0
        public void TestTrackableCollection_RemoveAndGetIndex(bool track)
        {
            var acc  = new Accumulator("test");
            var b    = new Simple("b");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), b, new Simple("c"), b
            };
            var idx = coll.RemoveAndGetIndex(b);

            Assert.AreEqual(1, idx);
            idx = coll.RemoveAndGetIndex(b);
            Assert.AreEqual(2, idx);

            if (track)
            {
                Assert.AreEqual(6, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
Example #45
0
        public void TestTrackableCollection_Insert(bool track)
        {
            var acc  = new Accumulator("test");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                new Simple("a"), b, new Simple("c")
            };

            coll.Insert(0, c);
            Assert.AreEqual(4, coll.Count);
            Assert.AreEqual(c, coll[0]);

            if (track)
            {
                Assert.AreEqual(4, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
Example #46
0
        public void TestTrackableCollection_Move_OutOfRange(bool track)
        {
            var acc  = new Accumulator("test");
            var a    = new Simple("a");
            var b    = new Simple("b");
            var c    = new Simple("c");
            var coll = new TrackableCollection <Simple>(acc, track)
            {
                a, b, c, b, c, b, b
            };

            coll.SafeMove(0, 10);
            Assert.AreEqual(6, coll.IndexOf(a));

            if (track)
            {
                Assert.AreEqual(8, acc.Records.Count);
            }
            else
            {
                Assert.AreEqual(0, acc.Records.Count);
            }
        }
Example #47
0
        public void TS()
        {
            if (Dialect is Oracle8iDialect)
            {
                return;
            }

            ISession     session = OpenSession();
            ITransaction txn     = session.BeginTransaction();

            Simple sim = new Simple();

            sim.Date = DateTime.Today;             // NB We don't use Now() due to the millisecond alignment problem with SQL Server
            session.Save(sim, 1L);
            IQuery q = session.CreateSQLQuery("select {sim.*} from Simple {sim} where {sim}.date_ = ?")
                       .AddEntity("sim", typeof(Simple));

            q.SetDateTime(0, sim.Date);
            Assert.AreEqual(1, q.List().Count, "q.List.Count");
            session.Delete(sim);
            txn.Commit();
            session.Close();
        }
Example #48
0
		public void WriteTest()
		{
			using( var stream = new MemoryStream() )
			using( var reader = new StreamReader( stream ) )
			using( var writer = new StreamWriter( stream ) )
			using( var csv = new CsvWriter( writer ) )
			{
				csv.Configuration.UseExcelLeadingZerosFormatForNumerics = true;

				var record = new Simple
				{
					Id = 1,
					Name = "09010",
				};

				csv.WriteRecord( record );

				writer.Flush();
				stream.Position = 0;

				var text = reader.ReadToEnd();
				Assert.AreEqual( "1,=\"09010\"\r\n", text );
			}
		}
Example #49
0
        public void SpecialCharTest()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();
                var entity = new Simple { SpecialCharTest = @"a!@#$%^&*()_+-=[]\{}|;':"",./<>?" };
                repository.TestRegex.Simple.Insert(new[] { entity });

                entity.SpecialCharTest = "x";
                TestUtility.ShouldFail<Rhetos.UserException>(
                    () => repository.TestRegex.Simple.Update(new[] { entity }),
                    "must match", "Property:SpecialCharTest");
            }
        }
Example #50
0
        public void WhitespaceTest()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);
                var entity = new Simple { WhitespaceTest = "a\r\nb\tc" };
                repository.TestRegex.Simple.Insert(new[] { entity });

                entity.WhitespaceTest = "x";
                TestUtility.ShouldFail(
                    () => repository.TestRegex.Simple.Update(new[] { entity }),
                    "UserException", "must match", "Property:WhitespaceTest");
            }
        }
Example #51
0
        public void ExactMatch2()
        {
            using (var executionContext = new CommonTestExecutionContext())
            {
                var repository = new Common.DomRepository(executionContext);
                var entity = new Simple { StringFrom200To249 = " 205" };

                TestUtility.ShouldFail(
                    () => repository.TestRegex.Simple.Insert(new[] { entity }),
                    "UserException", "StringFrom200To249 must be between 200 and 249", "Property:StringFrom200To249");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RepositoryTransaction"/> class.
 /// </summary>
 /// <param name="trans">The trans.</param>
 internal RepositoryTransaction(Simple.Data.SimpleTransaction trans)
 {
     _transaction = trans;
 }
Example #53
0
	public static int test_5_pass_static_struct () {
		s_v = get_simple (1);
		if (receive_simple (7, s_v, 9) != 0)
			return 0;
		return 5;
	}
Example #54
0
	static int receive_simple (int a, Simple v, int b) {
		if (v.a != 1)
			return 1;
		if (v.b != 2)
			return 2;
		if (v.c != 3)
			return 3;
		if (v.d != 4)
			return 4;
		if (a != 7)
			return 5;
		if (b != 9)
			return 6;
		return 0;
	}
Example #55
0
	static Simple get_simple (int v) {
		Simple r = new Simple ();
		r.a = v;
		r.b = (byte)(v + 1);
		r.c = (short)(v + 2);
		r.d = v + 3;

		return r;
	}
Example #56
0
		/// <summary>
		///   Times the execution of the given delegate
		/// </summary>
		static public TimeSpan Time (Simple a)
		{
			DateTime start = DateTime.Now;
			a ();
			return DateTime.Now - start;
		}
Example #57
0
        public void WhitespaceTest()
        {
            using (var container = new RhetosTestContainer())
            {
                var repository = container.Resolve<Common.DomRepository>();
                var entity = new Simple { WhitespaceTest = "a\r\nb\tc" };
                repository.TestRegex.Simple.Insert(new[] { entity });

                entity.WhitespaceTest = "x";
                TestUtility.ShouldFail<Rhetos.UserException>(
                    () => repository.TestRegex.Simple.Update(new[] { entity }),
                    "must match", "Property:WhitespaceTest");
            }
        }
        public void WriteRecordSepTest()
        {
            using( var stream = new MemoryStream() )
            using( var reader = new StreamReader( stream ) )
            using( var writer = new StreamWriter( stream ) )
            using( var csv = new CsvWriter( writer ) )
            {
                var record = new Simple
                {
                    Id = 1,
                    Name = "one",
                };

                csv.Configuration.Delimiter = ";";
                csv.Configuration.HasExcelSeparator = true;
                csv.WriteExcelSeparator();
                csv.WriteHeader<Simple>();
                csv.WriteRecord( record );

                writer.Flush();
                stream.Position = 0;

                var text = reader.ReadToEnd();

                Assert.AreEqual( "sep=;\r\nId;Name\r\n1;one\r\n", text );
            }
        }
        public void SerializationRespectsYamlIgnoreOverride()
        {

            var writer = new StringWriter();
            var obj = new Simple();

            var overrides = new YamlAttributeOverrides();
            var ignore = new YamlIgnoreAttribute();
            overrides.Add(typeof(Simple), "aaa", ignore);
            var serializer = new Serializer(overrides: overrides);
            
            serializer.Serialize(writer, obj);
            var serialized = writer.ToString();
            Dump.WriteLine(serialized);

            serialized.Should().NotContain("aaa");
        }
Example #60
0
        public void RoundtripArrayOfIdenticalObjects()
        {
            var z = new Simple { aaa = "bbb" };
            var obj = new[] { z, z, z };

            var result = DoRoundtripOn<Simple[]>(obj);

            result.Should().HaveCount(3).And.OnlyContain(x => z.aaa.Equals(x.aaa));
            result[0].Should().BeSameAs(result[1]).And.BeSameAs(result[2]);
        }