Beispiel #1
0
        public void StringUnion()
        {
            {
                var a = new MyA {
                    Age = 9999
                };

                var data = ZeroFormatterSerializer.Serialize <MyUnion>(a);

                var union = ZeroFormatterSerializer.Deserialize <MyUnion>(data);
                union.Key.Is("takotako");
                (union as MyA).Age.Is(9999);
            }

            {
                var b = new MyB {
                    Name = "nano"
                };

                var data = ZeroFormatterSerializer.Serialize <MyUnion>(b);

                var union = ZeroFormatterSerializer.Deserialize <MyUnion>(data);
                union.Key.Is("hogehoge");
                (union as MyB).Name.Is("nano");
            }
        }
Beispiel #2
0
        private void Main01()
        {
            MyA myA = new MyA(MyUtility.ReadInt("x1 ?= "), MyUtility.ReadInt("x0 ?= "));

            Console.WriteLine(myA.MyString());
            Console.WriteLine(myA.AllString());
        }
        public void RaisingEvents_NSubstitute()
        {
            var b = Substitute.For <IB>();
            var a = new MyA(b);

            b.MyEvent += Raise.Event <Action <IB, EventArgs> >(b, new EventArgs());

            Assert.That(a.EventRaised, Is.True);
        }
        public void RaisingEvents_Moq()
        {
            var b = new Mock <IB>();
            var a = new MyA(b.Object);

            b.Raise(x => x.MyEvent += null, b.Object, new EventArgs());

            Assert.That(a.EventRaised, Is.True);
        }
Beispiel #5
0
        public void Strict_FakeItEasy()
        {
            var b = A.Fake <IB>(x => x.Strict());

            A.CallTo(() => b.GetEmailAddress(A <UserCredentials> ._)).Returns("*****@*****.**");
            var a = new MyA(b);

            a.IsAuthenticated("userName");
        }
Beispiel #6
0
        private void Main02()
        {
            MyA a1 = new MyA(2, 3);
            MyA a0 = new MyA(5, 6);
            MyB b1 = new MyB(a1, a0);

            Console.WriteLine(b1.MyString());
            Console.WriteLine(b1.AllString());
        }
        public void RaisingEvents_FakeItEasy()
        {
            var b = A.Fake <IB>();
            var a = new MyA(b);

            b.MyEvent += FakeItEasy.Raise.FreeForm <Action <IB, EventArgs> > .With(b, new EventArgs());

            Assert.That(a.EventRaised, Is.True);
        }
Beispiel #8
0
        public void Strict_Moq()
        {
            var b = new Mock <IB>(MockBehavior.Strict);

            b.Setup(x => x.GetEmailAddress(It.IsAny <UserCredentials>())).Returns("*****@*****.**");
            var a = new MyA(b.Object);

            a.IsAuthenticated("userName");
        }
Beispiel #9
0
        private void Main01()
        {
            MyA myA01;

            myA01 = new MyA(MyUtility.ReadInt("x1 ?= "), MyUtility.ReadInt("x0 ?= "));
            Console.WriteLine("myA01={0}", myA01.MyString());
            Console.WriteLine("x1 = {0}", myA01.X1);
            myA01.X1 = 4;
            Console.WriteLine("myA01={0}", myA01.MyString());
        }
        public void Canonical_Moq()
        {
            var c = Mock.Of <IC>();
            var d = Mock.Of <ID>();
            var b = Mock.Of <IB>(x => x.GetC() == c && x.GetD() == d);
            var a = new MyA(b);

            Assert.That(a.GetDependencies(), Is.EqualTo((b, c, d)));
            Mock.Get(b).Verify(x => x.GetC());
            Mock.Get(b).Verify(x => x.GetD());
        }
Beispiel #11
0
        private void Main02()
        {
            MyA mB = new MyB(1, 2, 3, 4);
            MyA mC = mB.Copy();

            Console.WriteLine("mB: ({0})", mB);
            Console.WriteLine("mC: ({0})", mC);
            mC.X1 = 123;
            Console.WriteLine("mB: ({0})", mB);
            Console.WriteLine("mC: ({0})", mC);
        }
Beispiel #12
0
        private void Main01()
        {
            MyA myA0 = new MyA(MyUtility.Read("x2 ?="), MyUtility.Read("x1 ?="), MyUtility.Read("x0 ?="));

            Console.WriteLine("myA0 : {0})", myA0.ToString());
            MyA myA1;

            myA1    = myA0.Copy(); //Copy object
            myA1.X2 = MyUtility.Read("x2 ?=");
            Console.WriteLine("myA0 : {0})", myA0);
            Console.WriteLine("myA1 : {0})", myA1);
        }
Beispiel #13
0
        private void Main02()
        {
            MyA myA01, myA02;

            myA01 = new MyA(MyUtility.ReadInt("x1 ?= "), MyUtility.ReadInt("x0 ?= "));
            myA02 = myA01.Copy();
            Console.WriteLine("myA01={0}", myA01.MyString());
            Console.WriteLine("myA02={0}", myA02.MyString());
            myA02.X1 = 4;
            Console.WriteLine("_____________________________________________________");
            Console.WriteLine("myA01={0}", myA01.MyString());
            Console.WriteLine("myA02={0}", myA02.MyString());
        }
Beispiel #14
0
        private void Main03()
        {
            MyA a1 = new MyA(2, 3);
            MyA a0 = new MyA(5, 6);
            MyB b1 = new MyB(a1.Copy(), a0.Copy());
            MyB b0 = new MyB(a1.Copy(), a0.Copy());

            Console.WriteLine("b1: " + b1.MyString());
            Console.WriteLine("b0: " + b0.MyString());
            b1.x1.x1 = 123;
            Console.WriteLine("b1: " + b1.MyString());
            Console.WriteLine("b0: " + b0.MyString());
        }
Beispiel #15
0
        private void Main00()
        {
            MyA myA;

            myA = new MyA(1, 2, 3); //utworzenie obiektu
            myA.Print();
            myA.PrintAll();
            Console.WriteLine("myA.x2 = {0}", myA.X2); //using getter
            myA.X2 = 1;
            myA.X1 = 2;
            myA.X0 = 3;
            myA.PrintAll();
        }
Beispiel #16
0
        public void OutRef_FakeItEasy()
        {
            var b  = A.Fake <IB>();
            var k2 = 12;
            int i  = 0;
            int j  = 0;

            A.CallTo(() => b.MutateOperands(ref i, out j)).AssignsOutAndRefParameters(k2, 0);
            ;
            var a  = new MyA(b);
            var id = a.GetNextId();

            Assert.That(id, Is.EqualTo(k2));
        }
Beispiel #17
0
        public void OutRef_NSubstitute()
        {
            var b  = Substitute.For <IB>();
            var k2 = 12;
            int i  = 0;
            int j  = 0;

            b.When(x => x.MutateOperands(ref i, out j))
            .Do(x => { x[i] = k2; });
            var a  = new MyA(b);
            var id = a.GetNextId();

            Assert.That(id, Is.EqualTo(k2));
        }
Beispiel #18
0
        private void Main06()
        {
            MyA a1 = new MyA(MyUtility.ReadInt("x1 ?= "), MyUtility.ReadInt("x0 ?= "));
            MyA a0 = new MyA(MyUtility.ReadInt("x1 ?= "), MyUtility.ReadInt("x0 ?= "));

            if (a1 < a0)
            {
                Console.WriteLine(a1.MyString() + " < " + a0.MyString());
            }
            if (a1 > a0)
            {
                Console.WriteLine(a1.MyString() + " > " + a0.MyString());
            }
        }
        public void Canonical_FakeItEasy()
        {
            var d = A.Fake <ID>();
            var c = A.Fake <IC>();
            var b = A.Fake <IB>();

            A.CallTo(() => b.GetC()).Returns(c);
            A.CallTo(() => b.GetD()).Returns(d);
            var a = new MyA(b);

            Assert.That(a.GetDependencies(), Is.EqualTo((b, c, d)));
            A.CallTo(() => b.GetC()).MustHaveHappened();
            A.CallTo(() => b.GetD()).MustHaveHappened();
        }
        public void Canonical_NSubstitute()
        {
            var d = Substitute.For <ID>();
            var c = Substitute.For <IC>();
            var b = Substitute.For <IB>();

            b.GetC().Returns(c);
            b.GetD().Returns(d);
            var a = new MyA(b);

            Assert.That(a.GetDependencies(), Is.EqualTo((b, c, d)));
            b.Received().GetC();
            b.Received().GetD();
        }
Beispiel #21
0
        public void OutRef_Moq()
        {
            var b  = new Mock <IB>();
            var k2 = 12;

            b.Setup(x => x.MutateOperands(ref It.Ref <int> .IsAny, out It.Ref <int> .IsAny))
            .Callback(new MyCallback((ref int i, out int j) =>
            {
                i = k2;
                j = 0;
            }));
            var a  = new MyA(b.Object);
            var id = a.GetNextId();

            Assert.That(id, Is.EqualTo(k2));
        }
Beispiel #22
0
 private void Main03()
 {
     MyA[] mT = new MyA[20];
     for (int i = 0; i < mT.Length; ++i)
     {
         if (0 == MyUtility.myFate.Next(0, 3))
         {
             mT[i] = new MyA(MyUtility.myFate.Next(10, 51),
                             MyUtility.myFate.Next(10, 51));
         }
         else
         {
             mT[i] = new MyA(MyUtility.myFate.Next(51, 100),
                             MyUtility.myFate.Next(51, 100));
         }
     }
     for (int i = 0; i < mT.Length; ++i)
     {
         Console.WriteLine("mT[{0}] = {1}", i, mT[i].MyString());
     }
 }
 public B(MyA a)
 {
     _a = a;
     _a.PropertyChanged += Handler;
 }
Beispiel #24
0
 public MyB(MyA x1, MyA x0)
 {
     this.x1 = x1;
     this.x0 = x0;
 }
Beispiel #25
0
 public Empresa()
 {
     mya = new MyA();
 }