public void Will_Rollback_And_Dispose_Transaction_If_Flush_Throws()
		{
			// SQLite에서는 Length 제한이 안 먹네... 그래서 SQLite에서는 Rollback이 되지 않는다.
			//
			var obj = new SimpleObject { TwoCharactersMax = "This string is too big" };
			UnitOfWork.CurrentSession.Save(obj);

			var logMessages = NSoft.NFramework.With.Log(TransactionLogName, delegate
																	{
																		try
																		{
																			UnitOfWork.Current.TransactionalFlush();
																		}
																		catch { }
																	});

			bool hasRollback = false;
			foreach(string msg in logMessages)
			{
				if(msg.ToLower().Contains("rollback"))
				{
					hasRollback = true;
					break;
				}
			}

			if(CurrentContext.DatabaseEngine == DatabaseEngine.SQLite)
				Assert.IsFalse(hasRollback);
			else
				Assert.IsTrue(hasRollback);
		}
Ejemplo n.º 2
0
 public DoubleReferenceClass(SimpleObject obj1, SimpleObject obj2) : this()
 {
     Object1 = obj1;
     Object2 = obj2;
     List1.Add(obj1);
     List1.Add(obj2);
 }
Ejemplo n.º 3
0
        public void TestAllUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var so3 = new SimpleObject {ValueOne = 5, ValueTwo = 6};
            var so4 = new SimpleObject {ValueOne = 7, ValueTwo = 8};
            var ao = new AllObject {ValueOne = 9, ValueTwo = 10, ReferenceOne = so1};
            ao.CollectionOne.Add(so2);

            var clone = (AllObject) CopyUtils.CloneObjectTest(ao);

            clone.ValueTwo = 11;
            clone.ReferenceOne = so3;
            clone.CollectionOne.Add(so4);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreNotEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreNotSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreNotEqual(ao.CollectionOne.Count(), clone.CollectionOne.Count());

            CopyUtils.UpdateFromClone(ao, clone);

            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreEqual(ao.CollectionOne.Count(), clone.CollectionOne.Count());
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
            Assert.AreSame(ao.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1));
        }
Ejemplo n.º 4
0
 private void Awake() {
     baseScript = GetComponent<SimpleObject>();
     if(drop == null) {
         ItemEntities.Init();
         drop = new ItemStack(ItemEntities.items.Values.First());
     }
 }
Ejemplo n.º 5
0
	// Use this for initialization
	void Start () {
		gameObject.NewTrick( Vector3.one );
		//gameObject.transform.Zero();
		//gameObject.Zero();
		SimpleObject so = new SimpleObject(this.gameObject);
		UpdateEvent+=so.OnUpdate;
	}
Ejemplo n.º 6
0
 public virtual void Reset() {
     flagState = false;
     moveComponent.OnDone -= StartAction;
     moveComponent.OnChangeTarget -= Reset;
     target = null;
     currentTimeAction = 0;
     EndTimer();
 }
 public RecursiveObject()
 {
     Partner = new SimpleObject
     {
         FirstName = "Nicole",
         LastName = "Murphy",
         DateOfBirth = new DateTime(1970, 1, 1)
     };
 }
Ejemplo n.º 8
0
        public void Bind_Tries_To_Bind_Only_Property()
        {
            var instance = new SimpleObject();
            A.CallTo(() => resolveDependencies.Resolve(typeof (SimpleObject))).Returns(instance);

            modelBinder.Bind(typeof (SimpleObject), bindingContext);

            A.CallTo(() => propertyBinder.Bind(instance, instance.GetType().GetProperty("Test"), bindingContext)).MustHaveHappened(Repeated.Exactly.Once);
        }
Ejemplo n.º 9
0
        public void Bind_Returns_Null_When_No_Property_Is_Bound()
        {
            var instance = new SimpleObject();
            A.CallTo(() => resolveDependencies.Resolve(typeof(SimpleObject))).Returns(instance);
            A.CallTo(() => propertyBinder.Bind(instance, instance.GetType().GetProperty("Test"), bindingContext)).Returns(false);

            var result = modelBinder.Bind(typeof (SimpleObject), bindingContext);

            Assert.IsNull(result);
        }
Ejemplo n.º 10
0
        public void Bind_Returns_Null_When_No_PropertyBinder_Is_Found_For_Any_Property()
        {
            var instance = new SimpleObject();
            A.CallTo(() => resolveDependencies.Resolve(typeof(SimpleObject))).Returns(instance);
            A.CallTo(() => propertyBinderCollection.GetMatching(typeof (SimpleObject).GetProperty("Test"))).Returns(null);

            var result = modelBinder.Bind(typeof(SimpleObject), bindingContext);

            Assert.IsNull(result);
        }
Ejemplo n.º 11
0
        public void Serialize_Can_Serialize_A_Simple_Static_Type()
        {
            var testObject = new SimpleObject
                                 {
                                     Test = "test"
                                 };

            var serialized = jsonParser.Serialize(testObject);

            serialized.ShouldEqual("{\"Test\":\"test\"}");
        }
Ejemplo n.º 12
0
        public void TestCollectionClone() {
            var so = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var co = new CollectionObject();
            co.CollectionOne.Add(so);

            var clone = (CollectionObject) CopyUtils.CloneObjectTest(co);
            Assert.AreNotSame(co, clone);
            Assert.AreSame(co.GetType(), clone.GetType());
            Assert.AreNotSame(co.CollectionOne, clone.CollectionOne);
            Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First());
        }
Ejemplo n.º 13
0
 public void Action(SimpleObject obj) {
     if (target == obj && animator.GetInteger("State") == (int) state)
         return;
     Reset();
     target = obj;
     if (Vector2.Distance(transform.position, obj.transform.position) > 1f) {
         moveComponent.Move(obj.transform.position, 1f);
         moveComponent.OnDone += StartAction;
         moveComponent.OnChangeTarget += Reset;
     }
     else {
         StartAction();
     }
 }
Ejemplo n.º 14
0
        public void TestAllClone() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var ao = new AllObject {ValueOne = 5, ValueTwo = 6, ReferenceOne = so1};
            ao.CollectionOne.Add(so2);

            var clone = (AllObject) CopyUtils.CloneObjectTest(ao);
            Assert.AreNotSame(ao, clone);
            Assert.AreSame(ao.GetType(), clone.GetType());
            Assert.AreEqual(ao.ValueOne, clone.ValueOne);
            Assert.AreEqual(ao.ValueTwo, clone.ValueTwo);
            Assert.AreSame(ao.ReferenceOne, clone.ReferenceOne);
            Assert.AreNotSame(ao.CollectionOne, clone.CollectionOne);
            Assert.AreSame(ao.CollectionOne.First(), clone.CollectionOne.First());
        }
		public void BindingParameterCanOverrideInjectedValueForPropertyValue()
		{
			var child = new SimpleObject();

			var module = new InlineModule(
				m => m.Bind<RequestsPropertyInjection>().ToSelf().WithPropertyValue("Child", child)
			);

			using (var kernel = new StandardKernel(module))
			{
				var mock = kernel.Get<RequestsPropertyInjection>();

				Assert.That(mock, Is.Not.Null);
				Assert.That(mock.Child, Is.Not.Null);
				Assert.That(mock.Child, Is.SameAs(child));
			}
		}
		public void ContextParameterOverridesBindingParameterForConstructorArgument()
		{
			var childInBinding = new SimpleObject();
			var childInContext = new SimpleObject();

			var module = new InlineModule(
				m => m.Bind<RequestsConstructorInjection>().ToSelf().WithConstructorArgument("child", childInBinding)
			);

			using (var kernel = new StandardKernel(module))
			{
				var mock = kernel.Get<RequestsConstructorInjection>(With.Parameters.ConstructorArgument("child", childInContext));

				Assert.That(mock, Is.Not.Null);
				Assert.That(mock.Child, Is.Not.Null);
				Assert.That(mock.Child, Is.SameAs(childInContext));
			}
		}
Ejemplo n.º 17
0
 public bool Action(SimpleObject obj) {
     if (obj.gameObject == gameObject)
         return false;
     Component component = obj.gameObject.GetComponent("CanBeCollected");
     if (component != null) {
         collectComponent.Action(obj);
         return true;
     }
     component = obj.gameObject.GetComponent("CanBeAttacked");
     if (component != null) {
         attackComponent.Attack((CanBeAttacked)component);
         return true;
     }
     component = obj.gameObject.GetComponent("CanStore");
     if (component != null) {
         openComponent.Action(obj);
         return true;
     }
     return false;
 }
Ejemplo n.º 18
0
		public void TransientConstructorArgumentDefinedDirectlyOverridesInjection()
		{
			var module = new InlineModule(
				m => m.Bind<RequestsConstructorInjection>().ToSelf(),
				m => m.Bind<SimpleObject>().ToSelf()
			);

			using (var kernel = new StandardKernel(module))
			{
				var child = new SimpleObject();

				var obj = kernel.Get<RequestsConstructorInjection>(
					With.Parameters
						.ConstructorArgument("child", child)
				);

				Assert.That(obj, Is.Not.Null);
				Assert.That(obj.Child, Is.Not.Null);
				Assert.That(obj.Child, Is.SameAs(child));
			}
		}
Ejemplo n.º 19
0
        public override void onStart()
        {
            //This code runs when the GameObject is initialized
            Wall wall = Objects.getObject <Wall>("WALLPIPE");

            wall.Active = false;
            wall.X      = 10100;

            target    = Objects.getObject <DebugObject>("Phase1CameraSpot");
            water     = Objects.getObject <WaterBlock>("WaterBlock1");
            camMaster = Objects.getObject <CameraMaster>("CameraMaster1");
            //camMaster.getScript("CameraMasterControl").Active = false;

            obj                     = new SimpleObject(Level);
            obj.Position            = Gob.Position;
            obj.Sprite.Color        = Color.Red;
            obj.Sprite.Visible      = false;
            camMaster.Target        = obj.Name;
            camMaster.ObeyCamZones  = false;
            Level.Camera.TargetZoom = .55f;
        }
Ejemplo n.º 20
0
        public void TestSimpleSelect()
        {
            MockSimpleObject            obj   = new MockSimpleObject();
            Dictionary <string, string> props = new Dictionary <string, string>();

            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "full_name");
            obj.CommonName = null;
            obj.Id         = 5;

            //obj.FullName = string.Empty;
            //SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            SimpleObject newObj = dao.SimpleSelect(con, obj, props);

            con.Close();
        }
Ejemplo n.º 21
0
        public static int guessOperationCount(SimpleObject obj, int oc)
        {
            if (obj == null)
            {
                return(-1);
            }

            for (int i = 0; i < oc; i++)
            {
                obj.addAbs(1);
            }

            if (obj.getOperationCount() == 5)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 22
0
        public static int guessResult(SimpleObject obj, int x1, int x2,
                                      int x3)
        {
            if (obj == null)
            {
                return(-1);
            }

            obj.addAbs(x1);
            obj.addAbs(x2);
            obj.addAbs(x3);

            if (obj.getResult() == 10)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 23
0
            public static void AreEqual(SimpleObject expected, SimpleObject actual)
            {
                Assert.AreNotEqual(expected, actual);

                Assert.AreEqual(expected.MyBool, actual.MyBool);
                Assert.AreEqual(expected.MyByte, actual.MyByte);
                Assert.AreEqual(expected.MyChar, actual.MyChar);
                Assert.AreEqual(expected.MyDateTime, actual.MyDateTime);
                Assert.AreEqual(expected.MyDouble, actual.MyDouble);
                //[verify error with Guid, see case: 1306000763] Assert.AreEqual(expected.MyGuid, actual.MyGuid);
                Assert.AreEqual(expected.MyInt16, actual.MyInt16);
                Assert.AreEqual(expected.MyInt32, actual.MyInt32);
                Assert.AreEqual(expected.MyInt64, actual.MyInt64);
                Assert.AreEqual(expected.MySByte, actual.MySByte);
                Assert.AreEqual(expected.MySingle, actual.MySingle);
                Assert.AreEqual(expected.MyString, actual.MyString);
                Assert.AreEqual(expected.MyTimeSpan, actual.MyTimeSpan);
                Assert.AreEqual(expected.MyUInt16, actual.MyUInt16);
                Assert.AreEqual(expected.MyUInt32, actual.MyUInt32);
                Assert.AreEqual(expected.MyUInt64, actual.MyUInt64);
            }
Ejemplo n.º 24
0
        public void TransientPropertyValueDefinedDirectlyOverridesInjection()
        {
            var module = new InlineModule(
                m => m.Bind <RequestsPropertyInjection>().ToSelf(),
                m => m.Bind <SimpleObject>().ToSelf()
                );

            using (var kernel = new StandardKernel(module))
            {
                var child = new SimpleObject();

                var obj = kernel.Get <RequestsPropertyInjection>(
                    With.Parameters
                    .PropertyValue("Child", child)
                    );

                Assert.That(obj, Is.Not.Null);
                Assert.That(obj.Child, Is.Not.Null);
                Assert.That(obj.Child, Is.SameAs(child));
            }
        }
Ejemplo n.º 25
0
    public void CopyFromListToNonList()
    {
        // Arrange
        var targetObject = new SimpleObject()
        {
            IntegerList = new List <int>()
            {
                1, 2, 3
            }
        };

        var patchDocument = new JsonPatchDocument();

        patchDocument.Copy("IntegerList/0", "IntegerValue");

        // Act
        patchDocument.ApplyTo(targetObject);

        // Assert
        Assert.Equal(1, targetObject.IntegerValue);
    }
        public void TestSimpleUpdate()
        {
            var so = new SimpleObject {
                ValueOne = 1, ValueTwo = 2
            };
            var clone = (SimpleObject)CopyUtils.CloneObjectTest(so);

            clone.ValueTwo = 3;

            Assert.AreNotSame(so, clone);
            Assert.AreSame(so.GetType(), clone.GetType());
            Assert.AreEqual(so.ValueOne, clone.ValueOne);
            Assert.AreNotEqual(so.ValueTwo, clone.ValueTwo);

            CopyUtils.UpdateFromClone(so, clone);

            Assert.AreNotSame(so, clone);
            Assert.AreSame(so.GetType(), clone.GetType());
            Assert.AreEqual(so.ValueOne, clone.ValueOne);
            Assert.AreEqual(so.ValueTwo, clone.ValueTwo);
        }
Ejemplo n.º 27
0
        public void TransientConstructorArgumentDefinedViaAnonymousTypeOverridesInjection()
        {
            var module = new InlineModule(
                m => m.Bind <RequestsConstructorInjection>().ToSelf(),
                m => m.Bind <SimpleObject>().ToSelf()
                );

            using (var kernel = new StandardKernel(module))
            {
                var child = new SimpleObject();

                var obj = kernel.Get <RequestsConstructorInjection>(
                    With.Parameters
                    .ConstructorArguments(new { child })
                    );

                Assert.That(obj, Is.Not.Null);
                Assert.That(obj.Child, Is.Not.Null);
                Assert.That(obj.Child, Is.SameAs(child));
            }
        }                       /*----------------------------------------------------------------------------------------*/
        public void CanCreateSingleton()
        {
            string config =
                @"<object-builder-config xmlns=""pag-object-builder"">
               <build-rules>
						<build-rule type="""                         + FullNameSimpleObject + @""" mode=""Singleton"">
							<constructor-params>
								<value-param type=""System.Int32"">12</value-param>
							</constructor-params>
						</build-rule>
					</build-rules>
				</object-builder-config>"                ;

            Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
            Locator locator = CreateLocator();

            SimpleObject m1 = builder.BuildUp <SimpleObject>(locator, null, null);
            SimpleObject m2 = builder.BuildUp <SimpleObject>(locator, null, null);

            Assert.AreSame(m1, m2);
        }
        public void CanInjectValuesIntoProperties()
        {
            string config =
                @"<object-builder-config xmlns=""pag-object-builder"">
               <build-rules>
						<build-rule type="""                         + FullNameSimpleObject + @""" mode=""Instance"">
							<property name=""StringProperty"">
								<value-param type=""System.String"">Bar is here</value-param>
							</property>
						</build-rule>
					</build-rules>
				</object-builder-config>"                ;

            Builder builder = new Builder(ObjectBuilderXmlConfig.FromXml(config));
            Locator locator = CreateLocator();

            SimpleObject sm = builder.BuildUp <SimpleObject>(locator, null, null);

            Assert.IsNotNull(sm);
            Assert.AreEqual("Bar is here", sm.StringProperty);
        }
Ejemplo n.º 30
0
        public void SimpleObjectLinkedList()
        {
            Serializer s = new Serializer();
            LinkedList <SimpleObject> objects = new LinkedList <SimpleObject>();
            SimpleObject obj = null;

            // object 1
            obj             = new SimpleObject();
            obj.BoolValue   = true;
            obj.ByteValue   = 0xf1;
            obj.CharValue   = 'a';
            obj.DoubleValue = double.MinValue;
            obj.FloatValue  = float.MinValue;
            obj.IntValue    = 32;
            obj.LongValue   = 39000;
            obj.ShortValue  = 255;
            obj.StringValue = "AA";

            objects.AddLast(obj);

            // object 2
            obj             = new SimpleObject();
            obj.BoolValue   = false;
            obj.ByteValue   = 0xf2;
            obj.CharValue   = 'b';
            obj.DoubleValue = double.MaxValue;
            obj.FloatValue  = float.MaxValue;
            obj.IntValue    = 33;
            obj.LongValue   = 39001;
            obj.ShortValue  = 256;
            obj.StringValue = "BB";

            objects.AddLast(obj);

            string result = s.Serialize(objects);

            LinkedList <SimpleObject> actual = s.Deserialize <LinkedList <SimpleObject> >(result);

            CollectionAssert.AreEqual(objects, actual);
        }
Ejemplo n.º 31
0
    public static void SimpleIntegrationExample()
    {
        var inspected = new SimpleObject()
        {
            a = 1,
            b = 2
        };
        var previousState = new SavedObject(inspected);

        inspected.a = 5;

        var currentState = new SavedObject(inspected);

        var delta = new SavedObjectDelta(currentState, previousState);

        var hello = new SimpleObject();

        delta.ApplyChanges(ref hello);

        Assert.AreEqual(5, hello.a);
        Assert.AreEqual(0, hello.b);
    }
Ejemplo n.º 32
0
    public static void CheckReadableModelIncludesInstances()
    {
        var model = new SimpleObject {
            a      = 1,
            b      = 2,
            nested = new SimpleObject {
                a = 3,
                b = 4
            }
        };

        Dictionary <string, object> readable = SavedObjectDelta.ReadableModel(new SavedObject(model).state);

        Assert.AreEqual(7, readable.Count);
        Assert.AreEqual(model.GetType(), readable["GetType()"]);
        Assert.AreEqual(model.a, readable["a"]);
        Assert.AreEqual(model.b, readable["b"]);
        Assert.AreEqual(model.nested.GetType(), readable["nested:GetType()"]);
        Assert.AreEqual(model.nested.a, readable["nested:a"]);
        Assert.AreEqual(model.nested.b, readable["nested:b"]);
        Assert.AreEqual(model.nested.nested, readable["nested:nested"]);
    }
Ejemplo n.º 33
0
    public static void RunFieldPropertyTest()
    {
        var obj = new SimpleObject {
            a      = 1,
            b      = 2,
            nested = new SimpleObject {
                a = 3,
                b = 4
            }
        };
        Dictionary <ObjectDataPath[], object> model         = new SavedObject(obj).state;
        Dictionary <string, object>           readableModel = SavedObjectDelta.ReadableModel(model);

        Assert.AreEqual(7, readableModel.Count);
        Assert.AreEqual(obj.GetType(), readableModel["GetType()"]);
        Assert.AreEqual(1, readableModel["a"]);
        Assert.AreEqual(2, readableModel["b"]);
        Assert.AreEqual(obj.nested.GetType(), readableModel["nested:GetType()"]);
        Assert.AreEqual(3, readableModel["nested:a"]);
        Assert.AreEqual(4, readableModel["nested:b"]);
        Assert.AreEqual(null, readableModel["nested:nested"]);
    }
Ejemplo n.º 34
0
    public void Set_MultipeTasks_NoExceptions()
    {
        // Arrange
        const int numberOfItems = 100;
        var       items         = Enumerable.Range(0, numberOfItems).Select(i => SimpleObject.Create()).ToArray();
        var       cache         = cacheFactory.CreateDefault <SimpleObject>();

        // Act
        var stopwatch  = System.Diagnostics.Stopwatch.StartNew();
        var loopResult = Parallel.For(0, 20, i =>
        {
            var index = i % numberOfItems;
            var item  = items[index];
            cache.Set(new CacheItem <SimpleObject>("item-" + index, item, TimeSpan.FromSeconds(5)));
        });

        stopwatch.Stop();

        // Assert
        _output.WriteLine($"Duration: {stopwatch.Elapsed}");
        Assert.True(loopResult.IsCompleted);
    }
Ejemplo n.º 35
0
        public override void onStart()
        {
            laserSound = new Sound("gunfire.wav");

            //laserSound.Looped = true;

            //new Sound("gunfire.wav");

            target = new SimpleObject(Level);
            target.Sprite.Color  = new Color(255, 0, 0, 128);
            target.Light.Radius  = 64;
            target.Light.Color   = Color.Red;
            target.Light.Visible = true;
            target.IsDebug       = true;


            mouse = new SimpleObject(Level);
            mouse.Sprite.Depth   = 1;
            mouse.Sprite.Color   = Color.Blue;
            mouse.Sprite.Scale  *= .2f;
            mouse.Sprite.Visible = false;
        }
Ejemplo n.º 36
0
        private void btnAddShipArea_Click(object sender, RoutedEventArgs e)
        {
            var selArea = (AreaInfo)cmbArea.SelectedItem;

            if (!selArea.SysNo.HasValue)
            {
                this.Message("请先选择配送区域!");
                return;
            }

            var selectedItem = _model.ShipAreaSettingValue.Where(x => x.ID == selArea.SysNo.Value.ToString());

            if (selectedItem != null && selectedItem.Count() > 0)
            {
                this.Message(string.Format("已经存在相同的配送区域【{0}】!", selectedItem.First().Name));
                return;
            }

            SimpleObject simpleObject = new SimpleObject(selArea.SysNo, selArea.SysNo.Value.ToString(), selArea.ProvinceName);

            _model.ShipAreaSettingValue.Add(simpleObject);
        }
Ejemplo n.º 37
0
        /// <summary>
        /// The main method.
        /// </summary>
        static void Main()
        {
            Console.WriteLine("InterLinq.Examples.Simple.Server is going to start...");

            // Create an ExampleObjectSource
            Console.WriteLine("Creating an ExampleObjectSource...");
            ExampleObjectSource exampleObjectSource = new ExampleObjectSource();

            // Create 20 SimpleObjects and store them in the objectDataSource
            Console.WriteLine("Creating some SimpleObjects into ExampleObjectSource...");
            for (int i = 0; i < 20; i++)
            {
                SimpleObject simpleObject = new SimpleObject();
                simpleObject.Name  = string.Format("Object #{0}", i);
                simpleObject.Value = i;
                exampleObjectSource.SimpleObjects.Add(simpleObject);
            }

            // Create a IQueryHandler for requests sent to this server
            Console.WriteLine("Creating an ObjectQueryHandler...");
            IQueryHandler queryHandler = new ObjectQueryHandler(exampleObjectSource);

            // Publish the IQueryHandler by InterLINQ over WCF
            Console.WriteLine("Publishing service...");
            using (ServerQueryWcfHandler serverQueryHandler = new ServerQueryWcfHandler(queryHandler))
            {
                serverQueryHandler.Start(true);
                Console.WriteLine("Server is started and running.");
                Console.WriteLine();

                // Wait for user input
                Console.WriteLine("Press [Enter] to quit.");
                Console.ReadLine();

                // Close the service
                Console.WriteLine("Closing service...");
            }
            Console.WriteLine("Bye");
        }
Ejemplo n.º 38
0
    public void NonGenericPatchDocToGenericMustSerialize()
    {
        // Arrange
        var targetObject = new SimpleObject()
        {
            StringProperty        = "A",
            AnotherStringProperty = "B"
        };

        var patchDocument = new JsonPatchDocument();

        patchDocument.Copy("StringProperty", "AnotherStringProperty");

        var serialized   = JsonConvert.SerializeObject(patchDocument);
        var deserialized = JsonConvert.DeserializeObject <JsonPatchDocument <SimpleObject> >(serialized);

        // Act
        deserialized.ApplyTo(targetObject);

        // Assert
        Assert.Equal("A", targetObject.AnotherStringProperty);
    }
Ejemplo n.º 39
0
        //@SetteRequiredStatementCoverage(value = 90)
        public static int guessImpossibleResult(SimpleObject obj, int x1,
                                                int x2, int x3)
        {
            if (obj == null)
            {
                return(-1);
            }

            obj.addAbs(x1);
            obj.addAbs(x2);
            obj.addAbs(x3);

            if (obj.getResult() < 0)
            {
                // only with overflow
                return(1);
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 40
0
        public void Add_CompatibleTypeWorks()
        {
            // Arrange
            var sDto         = new SimpleObject();
            var iDto         = new InheritedObject();
            var targetObject = new List <SimpleObject> {
                sDto
            };
            var listAdapter = new ListAdapter();
            var options     = new JsonSerializerOptions();

            // Act
            var addStatus = listAdapter.TryAdd(targetObject, typeof(List <SimpleObject>), "-", options, iDto, out var message);

            // Assert
            Assert.True(addStatus);
            Assert.True(string.IsNullOrEmpty(message), "Expected no error message");
            Assert.Equal(2, targetObject.Count);
            Assert.Equal(new List <SimpleObject> {
                sDto, iDto
            }, targetObject);
        }
        public void CopyFromListToEndOfList()
        {
            // Arrange
            var targetObject = new SimpleObject
            {
                IntegerList = new List <int> {
                    1, 2, 3
                }
            };

            var patchDocument = new JsonPatchDocument();

            patchDocument.Copy("IntegerList/0", "IntegerList/-");

            // Act
            patchDocument.ApplyTo(targetObject);

            // Assert
            Assert.Equal(new List <int> {
                1, 2, 3, 1
            }, targetObject.IntegerList);
        }
Ejemplo n.º 42
0
        private void btnAddPayType_Click(object sender, RoutedEventArgs e)
        {
            var selPaytype = cmbPayType.SelectedPayTypeItem;

            if (!selPaytype.SysNo.HasValue)
            {
                this.Message("请先选择支付类型!");
                return;
            }

            var selectedItem = _model.PayTypeSettingValue.Where(x => x.ID == selPaytype.SysNo.Value.ToString());

            if (selectedItem != null && selectedItem.Count() > 0)
            {
                this.Message(string.Format("已经存在相同的支付方式【{0}】!", selectedItem.First().Name));
                return;
            }

            SimpleObject simpleObject = new SimpleObject(selPaytype.SysNo, selPaytype.SysNo.Value.ToString(), selPaytype.PayTypeName);

            _model.PayTypeSettingValue.Add(simpleObject);
        }
        public void RemoveFromList()
        {
            // Arrange
            var targetObject = new SimpleObject
            {
                IntegerList = new List <int> {
                    1, 2, 3
                }
            };

            var patchDocument = new JsonPatchDocument();

            patchDocument.Remove("IntegerList/2");

            // Act
            patchDocument.ApplyTo(targetObject);

            // Assert
            Assert.Equal(new List <int> {
                1, 2
            }, targetObject.IntegerList);
        }
Ejemplo n.º 44
0
        public static void SimpleObjectComparison(
            int leftFoo, string leftBar, int rightFoo, string rightBar, bool expectedResult, string method, SimpleObject left, SimpleObject right, bool result)
        {
            "Given a simple object with Foo={0} and Bar='{1}'"
            .Given(() => left = new SimpleObject {
                Foo = leftFoo, Bar = leftBar
            });

            "And another simple object with Foo={2} and Bar='{3}'"
            .And(() => right = new SimpleObject {
                Foo = rightFoo, Bar = rightBar
            });

            "When I compare the objects using '{5}'"
            .When(() =>
            {
                switch (method)
                {
                case "op_Equality":
                    result = left == right;
                    break;

                case "op_Inequality":
                    result = left != right;
                    break;

                case "Equals":
                    result = left.Equals(right);
                    break;

                case "Object.Equals":
                    result = ((object)left).Equals(right);
                    break;
                }
            });

            "Then the result should be {4}"
            .Then(() => result.Should().Be(expectedResult));
        }
        public void Will_Rollback_And_Dispose_Transaction_If_Flush_Throws()
        {
            // SQLite에서는 Length 제한이 안 먹네... 그래서 SQLite에서는 Rollback이 되지 않는다.
            //
            var obj = new SimpleObject {
                TwoCharactersMax = "This string is too big"
            };

            UnitOfWork.CurrentSession.Save(obj);

            var logMessages = NSoft.NFramework.With.Log(TransactionLogName, delegate
            {
                try
                {
                    UnitOfWork.Current.TransactionalFlush();
                }
                catch { }
            });

            bool hasRollback = false;

            foreach (string msg in logMessages)
            {
                if (msg.ToLower().Contains("rollback"))
                {
                    hasRollback = true;
                    break;
                }
            }

            if (CurrentContext.DatabaseEngine == DatabaseEngine.SQLite)
            {
                Assert.IsFalse(hasRollback);
            }
            else
            {
                Assert.IsTrue(hasRollback);
            }
        }
        public void Move_KeepsObjectReferenceInList()
        {
            // Arrange
            var simpleObject1 = new SimpleObject {
                IntegerValue = 1
            };
            var simpleObject2 = new SimpleObject {
                IntegerValue = 2
            };
            var simpleObject3 = new SimpleObject {
                IntegerValue = 3
            };
            var targetObject = new SimpleObjectWithNestedObject
            {
                SimpleObjectList = new List <SimpleObject>
                {
                    simpleObject1,
                    simpleObject2,
                    simpleObject3
                }
            };

            var patchDocument = new JsonPatchDocument <SimpleObjectWithNestedObject>();

            patchDocument.Move(o => o.SimpleObjectList, 0, o => o.SimpleObjectList, 1);

            // Act
            patchDocument.ApplyTo(targetObject);

            // Assert
            Assert.Equal(new List <SimpleObject> {
                simpleObject2, simpleObject1, simpleObject3
            }, targetObject.SimpleObjectList);
            Assert.Equal(2, targetObject.SimpleObjectList[0].IntegerValue);
            Assert.Equal(1, targetObject.SimpleObjectList[1].IntegerValue);
            Assert.Same(simpleObject2, targetObject.SimpleObjectList[0]);
            Assert.Same(simpleObject1, targetObject.SimpleObjectList[1]);
        }
Ejemplo n.º 47
0
        public static Shape DrawObject(SimpleObject o)
        {
            Shape drawObj;

            if (o is IntersectionLibrary.LineSegment)
            {
                drawObj = DrawLineSegment(o.args);
            }
            else if (o is RayLine)
            {
                drawObj = DrawRayLine(o.args);
            }
            else if (o is StraightLine)
            {
                drawObj = DrawStraightLine(o.args);
            }
            else
            {
                drawObj = DrawCircle(o.args);
            }

            return(drawObj);
        }
Ejemplo n.º 48
0
        public void SerializeComplexObjectWithList()
        {
            var simpleObject = new SimpleObject {
                Integer = 3, SomeString = "test"
            };
            var complexObjectWithList = new ComplexObjectWithList {
                Number = 4, SimpleObjects = new List <SimpleObject> {
                    simpleObject
                }, Numbers = new List <int> {
                    1, 2, 3
                }
            };

            var model = complexObjectWithList.ToKO();

            model.ToJavascriptObject(ObjectName).Simplify().Should().BeInObject(ObjectName,
                                                                                "this.number: ko.observable(4);" +
                                                                                "this.simpleObjects: ko.observableArray([{" +
                                                                                "integer: ko.observable(3), " +
                                                                                "someString: ko.observable('test')" +
                                                                                "}]);" +
                                                                                "this.numbers: ko.observableArray([1, 2, 3]);".Simplify());
        }
        public void CanConvertSimpleObjectsToDictionary()
        {
            // Arrange
              object o1 = new { A = 10, B = "Train", C = true };
              object o2 = new SimpleObject { X = 10, Y = "Train", Z = true };

              // Act
              Dictionary<string, string> d1 = DictionaryConverter.ConvertObjectPropertiesToDictionary(o1);
              Dictionary<string, string> d2 = DictionaryConverter.ConvertObjectPropertiesToDictionary(o2);

              // Assert
              Assert.IsNotNull(d1);
              Assert.IsNotNull(d2);
              Assert.AreEqual(3, d1.Count);
              Assert.AreEqual(4, d2.Count);

              Assert.AreEqual("10", d1["A"]);
              Assert.AreEqual("Train", d1["B"]);
              Assert.AreEqual("True", d1["C"]);
              Assert.AreEqual("10", d2["X"]);
              Assert.AreEqual("Train", d2["Y"]);
              Assert.AreEqual("True", d2["Z"]);
        }
Ejemplo n.º 50
0
        public void TestCollectionUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var co = new CollectionObject();
            co.CollectionOne.Add(so1);

            var clone = (CollectionObject) CopyUtils.CloneObjectTest(co);

            clone.CollectionOne.Add(so2);

            Assert.AreNotSame(co, clone);
            Assert.AreSame(co.GetType(), clone.GetType());
            Assert.AreNotSame(co.CollectionOne, clone.CollectionOne);
            Assert.AreNotEqual(co.CollectionOne.Count(), clone.CollectionOne.Count());

            CopyUtils.UpdateFromClone(co, clone);

            Assert.AreNotSame(co, clone);
            Assert.AreSame(co.GetType(), clone.GetType());
            Assert.AreNotSame(co.CollectionOne, clone.CollectionOne);
            Assert.AreEqual(co.CollectionOne.Count(), clone.CollectionOne.Count());
            Assert.AreSame(co.CollectionOne.First(), clone.CollectionOne.First());
            Assert.AreSame(co.CollectionOne.ElementAt(1), clone.CollectionOne.ElementAt(1));
        }
Ejemplo n.º 51
0
        public void TestNodeConstruction()
        {
            var simpleObject = new SimpleObject(1, 2, 3, 4) { Name = "Test", MemberToIgnore = int.MaxValue, SubObject = new SimpleObject(5, 6, 7, 8) };
            simpleObject.Collection.Add("List Item");
            simpleObject.Collection.Add(22.5);
            simpleObject.Collection.Add(Guid.NewGuid());
            simpleObject.Collection.Add(new List<string> { "one", "two", "three" });
            simpleObject.Collection.Add(new SimpleObject(9, 10, 11, 12));
            simpleObject.Dictionary.Add("Item1", "List Item");
            simpleObject.Dictionary.Add("Item2", 22.5);
            simpleObject.Dictionary.Add("Item3", Guid.NewGuid());
            simpleObject.Dictionary.Add("Item4", new List<string> { "one", "two", "three" });
            simpleObject.Dictionary.Add("Item5", new SimpleObject(9, 10, 11, 12));
            var container = new ModelContainer();
            var node = (ModelNode)container.GetOrCreateModelNode(simpleObject, simpleObject.GetType());
            Console.WriteLine(node.PrintHierarchy());

            var visitor = new ModelConsistencyCheckVisitor(container.NodeBuilder);
            visitor.Check(node, simpleObject, typeof(SimpleObject), true);

            foreach (var viewModel in container.Models)
            {
                visitor.Check((ModelNode)viewModel, viewModel.Content.Value, viewModel.Content.Type, true);
                Console.WriteLine(viewModel.PrintHierarchy());
            }
        }
Ejemplo n.º 52
0
 public ComplexObject(SimpleObject monk)
 {
     SimpleObject = monk;
 }
Ejemplo n.º 53
0
        public void TestReferenceUpdate() {
            var so1 = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var so2 = new SimpleObject {ValueOne = 3, ValueTwo = 4};
            var ro = new ReferenceObject {ReferenceOne = so1};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);
            clone.ReferenceOne = so2;

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreNotSame(ro.ReferenceOne, clone.ReferenceOne);

            CopyUtils.UpdateFromClone(ro, clone);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());
            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }
Ejemplo n.º 54
0
        public void TestSimpleUpdate() {
            var so = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var clone = (SimpleObject) CopyUtils.CloneObjectTest(so);
            clone.ValueTwo = 3;

            Assert.AreNotSame(so, clone);
            Assert.AreSame(so.GetType(), clone.GetType());
            Assert.AreEqual(so.ValueOne, clone.ValueOne);
            Assert.AreNotEqual(so.ValueTwo, clone.ValueTwo);

            CopyUtils.UpdateFromClone(so, clone);

            Assert.AreNotSame(so, clone);
            Assert.AreSame(so.GetType(), clone.GetType());
            Assert.AreEqual(so.ValueOne, clone.ValueOne);
            Assert.AreEqual(so.ValueTwo, clone.ValueTwo);
        }
		/*----------------------------------------------------------------------------------------*/
		public RequestsConstructorInjectionWithoutAttribute(SimpleObject child, string foo)
		{
			Child = child;
		}
Ejemplo n.º 56
0
        private static void WriteSimpleObjectToXML(XmlWriter writer, SimpleObject obj)
        {
            writer.WriteStartElement("SimpleObject");

            writer.WriteAttributeString("area", obj.m_Area.ToString());
            writer.WriteAttributeString("star", obj.m_Layer.ToString());
            if (obj.ID != 511)
                writer.WriteComment(ObjectDatabase.m_ObjectInfo[obj.ID].m_InternalName);
            writer.WriteElementString("ObjectID", obj.ID.ToString());

            writer.WriteStartElement("Position");
            writer.WriteElementString("X", obj.Position.X.ToString(usa));
            writer.WriteElementString("Y", obj.Position.Y.ToString(usa));
            writer.WriteElementString("Z", obj.Position.Z.ToString(usa));
            writer.WriteEndElement();

            writer.WriteStartElement("Parameters");
            writer.WriteAttributeString("count", "1");
            for (int j = 0; j < 1; j++)
            {
                writer.WriteStartElement("Parameter");
                writer.WriteAttributeString("id", j.ToString());
                writer.WriteString(obj.Parameters[j].ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Ejemplo n.º 57
0
        public void TestNodeConstruction()
        {
            var obj = new SimpleObject(1, 2, 3, 4)
            {
                Name = "Test",
                MemberToIgnore = int.MaxValue,
                SubObject = new SimpleObject(5, 6, 7, 8),
                Collection = 
                {
                    "List Item",
                    22.5,
                    Guid.NewGuid(),
                    new List<string> { "one", "two", "three" },
                    new SimpleObject(9, 10, 11, 12),
                },
                Dictionary =
                {
                    { "Item1", "List Item" },
                    { "Item2", 22.5 },
                    { "Item3", Guid.NewGuid() },
                    { "Item4", new List<string> { "one", "two", "three" } },
                    { "Item5", new SimpleObject(9, 10, 11, 12) },
                },
            };

            var container = new NodeContainer();
            var node = (GraphNode)container.GetOrCreateNode(obj);
            Helper.PrintModelContainerContent(container, node);
            // Run the consistency check to verify construction.
            Helper.ConsistencyCheck(container, obj);
        }
Ejemplo n.º 58
0
 public DoubleReferenceClass(SimpleObject obj) : this()
 {
     Object1 = obj;
     Object2 = obj;
     List1.Add(obj);
 }
		public void Will_Not_Start_Transaction_If_Already_Started()
		{
			UnitOfWork.Current.BeginTransaction();

			var obj = new SimpleObject();
			obj.TwoCharactersMax = "This string is too big";
			UnitOfWork.CurrentSession.Save(obj);

			var logMessages = NSoft.NFramework.With.Log(TransactionLogName,
												delegate
												{
													try
													{
														UnitOfWork.Current.TransactionalFlush();
													}
													catch { }
												});

			//
			// 이미 trasaction이 시작되었으므로, 
			// TransactionalFlush() 하는 동안에는 begin transaction 이란 말이 들어가지 않는다.
			//
			Assert.IsFalse(logMessages.Contains("begin"));
		}
Ejemplo n.º 60
0
        public void TestReferenceClone() {
            var so = new SimpleObject {ValueOne = 1, ValueTwo = 2};
            var ro = new ReferenceObject {ReferenceOne = so};

            var clone = (ReferenceObject) CopyUtils.CloneObjectTest(ro);

            Assert.AreNotSame(ro, clone);
            Assert.AreSame(ro.GetType(), clone.GetType());

            Assert.AreSame(ro.ReferenceOne, clone.ReferenceOne);
        }