public void TryValidateObject_Throws_ValidationException_When_Property_Is_NullableAndRequired_And_Value_Is_Null ()
		{
			EntityMock entity = new EntityMock ();
			ICollection<ValidationResult> result = new List<ValidationResult> ();

			// Year = null
			bool isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A1-1");
			Assert.AreEqual (2, result.Count, "#A1-2");

			// Name = null, string
			result.Clear ();

			isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A2-1");
			Assert.AreEqual (2, result.Count, "#A2-2");

			// Name = string.Empty, string
			result.Clear ();

			entity.Name = String.Empty;
			isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A3-1");
			Assert.AreEqual (2, result.Count, "#A3-2");
		}
		public void TryValidateValue_Throws_ValidationException_When_Property_Is_NullableAndRequired_And_Value_Is_Null ()
		{
			EntityMock entity = new EntityMock ();
			ICollection<ValidationResult> result = new List<ValidationResult>();

			ICollection<ValidationAttribute> attributes = new List<ValidationAttribute> ();
			attributes.Add (new RequiredAttribute ());

			// Year = null
			bool isValid = Validator.TryValidateValue (null, new ValidationContext (entity, null, null) { MemberName = "Year" }, result, attributes);

			Assert.IsFalse (isValid, "#A1-1");
			Assert.AreEqual (1, result.Count, "#A1-2");

			// Name = null, string
			result.Clear ();

			isValid = Validator.TryValidateValue (null, new ValidationContext (entity, null, null) { MemberName =  "Name" }, result, attributes);

			Assert.IsFalse (isValid, "#A2-1");
			Assert.AreEqual (1, result.Count, "#A2-2");

			// Name = string.Empty, string
			result.Clear ();

			isValid = Validator.TryValidateValue (String.Empty, new ValidationContext (entity, null, null) { MemberName = "Name" }, result, attributes);

			Assert.IsFalse (isValid, "#A3-1");
			Assert.AreEqual (1, result.Count, "#A3-2");
		}
        public void EntityBase_TwoInstances_NotEquals()
        {
            var entityMock1 = new EntityMock();
            var entityMock2 = new EntityMock();

            Assert.That(entityMock1 != entityMock2);
        }
        public void EntityBase_TwoSameInstances_Equals()
        {
            var entityMock        = new EntityMock();
            var anotherEntityMock = entityMock;

            Assert.That(entityMock == anotherEntityMock);
        }
Beispiel #5
0
        public void WhenGettingSchemaItShouldReturnFullSchema()
        {
            const string schema = @"{
              'type': 'object',
              'properties': {
                'shoe_size': { 'type': 'number', 'minimum': 5, 'maximum': 12, 'multipleOf': 1.0 }
              }
            }";

            var entityMock = new EntityMock {
                ExtensionDataJsonSchema = schema
            };

            entityMock.JsonSchema.JsonEquals(@"{
                ""$id"": ""V.Udodov.Json.Tests.EntityTests+EntityMock"",
                ""type"": ""object"",
                ""properties"": {
                    ""name"": {
                        ""type"": [
                            ""string"",
                            ""null""
                                ]
                    },
                    ""shoe_size"": { 
                        ""type"": ""number"", 
                        ""minimum"": 5.0, 
                        ""maximum"": 12.0, 
                        ""multipleOf"": 1.0 
                    }
                },
                ""required"": [
                    ""name""
                    ]
                }");
        }
Beispiel #6
0
        public void EntitySerializationHasId()
        {
            EntityMock em  = new EntityMock();
            XDocument  doc = SerializerHelper.SerializeObject(em);

            Assert.NotEmpty(doc.Descendants(DMTId.IdTagName));
        }
Beispiel #7
0
        public void EntityDeserializerHasCorrectId()
        {
            var em = new EntityMock();

            var em2 = SerializerHelper.DeserializeObject <EntityMock>(SerializerHelper.SerializeObject(em));

            Assert.Equal(em.Id, em2.Id);
        }
Beispiel #8
0
        public void EntityEqualityWhenComparedToSelf()
        {
            EntityMock em    = new EntityMock();
            EntityMock other = em;

            Assert.True(em.Equals(em));
            Assert.True(em.Equals(other));
        }
Beispiel #9
0
        public void SetParentTest()
        {
            EntityMock mockEntity   = new EntityMock();
            EntityMock parentEntity = new EntityMock();

            mockEntity.SetParent(parentEntity);
            Assert.AreEqual(parentEntity, mockEntity.parent, "Parent objects are not equal");
        }
Beispiel #10
0
        public void SetParentTestHierarchyLoop()
        {
            EntityMock mockEntity   = new EntityMock();
            EntityMock parentEntity = new EntityMock();

            parentEntity.SetParent(mockEntity);
            mockEntity.SetParent(parentEntity);
        }
Beispiel #11
0
        public void DestroyEntityTestSuccess()
        {
            MockScene  scene   = new MockScene();
            EntityMock entity  = new EntityMock();
            EntityMock created = scene.CreateEntity(entity) as EntityMock;

            Assert.IsTrue(scene.DestroyEntity(entity), "object was not existing");
        }
Beispiel #12
0
        public void CreateEntityTest()
        {
            MockScene  scene   = new MockScene();
            EntityMock entity  = new EntityMock();
            EntityMock created = scene.CreateEntity(entity) as EntityMock;

            Assert.AreEqual(created, entity, "created entity is not same as mocked entity");
        }
Beispiel #13
0
        public void CreateEntityTestAddMultipleTimes()
        {
            MockScene  scene    = new MockScene();
            EntityMock entity   = new EntityMock();
            EntityMock created  = scene.CreateEntity(entity) as EntityMock;
            EntityMock created2 = scene.CreateEntity(entity) as EntityMock;

            Assert.AreEqual(created2, null, "Same entity got created");
        }
Beispiel #14
0
        public void DestroyEntityNotExistingObject()
        {
            MockScene  scene   = new MockScene();
            EntityMock entity  = new EntityMock();
            EntityMock entity2 = new EntityMock();
            EntityMock created = scene.CreateEntity(entity) as EntityMock;

            Assert.IsFalse(scene.DestroyEntity(entity2));
        }
Beispiel #15
0
        public void LiteDbDataService_Cannot_Update_Nonexistent_Entity()
        {
            // Set up
            var entity = new EntityMock {
                Name = Randomize.String()
            };

            // Act & Assert
            Assert.Throws <ArgumentException>(() => this.dataService.Update(entity));
        }
        public void EntityBase_Should_Generate_Id()
        {
            // Set Up
            var entity = new EntityMock();

            // Act

            // Assert
            entity.Id.ShouldNotBeNull();
            entity.Id.ShouldNotBe(Guid.Empty);
        }
Beispiel #17
0
        public void WhenSettingEntityFlexibleDataWithoutSchemaItShouldSetIt()
        {
            var entityMock = new EntityMock
            {
                ["shoe_size"]         = 12,
                ["coffee_preference"] = "cappuccino"
            };

            entityMock["shoe_size"].Should().Be(12);
            entityMock["coffee_preference"].Should().Be("cappuccino");
        }
Beispiel #18
0
        public void GetParentWorldPosTestNoParent()
        {
            EntityMock entity = new EntityMock();
            Vector2    newPos = new Vector2(10f, 10f);

            entity.transform.SetPosition(newPos);
            Vector2 expected = new Vector2(10f, 10f);
            Vector2 actual   = entity.transform.GetParentWorldPos();

            Assert.AreEqual(expected, actual, "Gauta bloga pozicija nesant tėvinei esybei");
        }
Beispiel #19
0
        public void FindChildTest()
        {
            EntityMock parentEntity = new EntityMock();
            EntityMock childEntity1 = new EntityMock();
            EntityMock childEntity2 = new EntityMock();

            childEntity1.SetParent(parentEntity);
            childEntity2.SetParent(parentEntity);
            EntityMock child = parentEntity.FindChild <EntityMock>();

            Assert.AreEqual(child, childEntity1, "Got wrong child object");
        }
Beispiel #20
0
        public void WhenTryingToGetWrongFlexibleDataEntityItemItShouldThrow()
        {
            var entityMock = new EntityMock
            {
                ["shoe_size"] = 12
            };

            entityMock.TryGetValue("pants_size", out var result)
            .Should().BeFalse();

            result.Should().BeNull();
        }
Beispiel #21
0
        public void WhenTryingToGetFlexibleDataEntityItemItShouldThrow()
        {
            var entityMock = new EntityMock
            {
                ["shoe_size"] = 12
            };

            entityMock.TryGetValue("shoe_size", out var result)
            .Should().BeTrue();

            result.Should().Be(12);
        }
Beispiel #22
0
        public void EntityEqualityIsBasedOnId()
        {
            IId id          = DMTId.NewId();
            var factoryMock = new Mock <IEntityFactory>();

            factoryMock.Setup(f => f.CreateId()).Returns(id);

            var em1 = new EntityMock(factoryMock.Object);
            var em2 = new EntityMock(factoryMock.Object);

            Assert.True(em1.Equals(em2));
        }
Beispiel #23
0
        public void SetPositionTestNoParent()
        {
            EntityMock entity    = new EntityMock();
            Transform  transform = new Transform(entity);
            Vector2    newPos    = new Vector2(10f, 10f);

            transform.SetPosition(newPos);
            Vector2 expected = newPos;
            Vector2 actual   = transform.position;

            Assert.AreEqual(expected, actual, "Nesutampa norima gauti pozicija su gauta");
        }
        public void EntityBase_InstanceNotInList_NotFound()
        {
            var entityMock = new EntityMock();
            var lookup     = new List <EntityMock>
            {
                new EntityMock(),
                new EntityMock(),
                new EntityMock()
            };

            Assert.That(!lookup.Contains(entityMock));
        }
Beispiel #25
0
        public void WhenTryingToGetWrongFlexibleDataEntityItemThroughIndexerItShouldThrow()
        {
            var entityMock = new EntityMock
            {
                ["shoe_size"] = 12
            };

            Action action = () =>
            {
                var pants = entityMock["pants_size"];
            };

            action.Should().Throw <KeyNotFoundException>();
        }
Beispiel #26
0
        public void TranslateTestNoParent()
        {
            EntityMock entity    = new EntityMock();
            Transform  transform = new Transform(entity);
            Vector2    newPos    = new Vector2(10f, 10f);

            transform.SetPosition(newPos);
            Vector2 offset = new Vector2(2f, 2f);

            transform.Translate(offset);
            Vector2 expected = new Vector2(12f, 12f);
            Vector2 actual   = transform.position;

            Assert.AreEqual(expected, actual, "Nesutampa norima gauti pozicija su gauta po pastūmimo");
        }
Beispiel #27
0
        public void WhenGettingEntityAsAStringItShouldSerializeIt()
        {
            var entityMock = new EntityMock
            {
                Name                  = "Peter Parker",
                ["shoe_size"]         = 12,
                ["coffee_preference"] = "cappuccino"
            };

            entityMock.ToString().JsonEquals(@"{
              ""name"": ""Peter Parker"",
              ""shoe_size"": 12,
              ""coffee_preference"": ""cappuccino""
            }");
        }
Beispiel #28
0
        public void LiteDbDataService_Can_Create_And_Read_Entity()
        {
            // Set up
            var entity = new EntityMock {
                Name = Randomize.String()
            };

            // Act
            this.dataService.Insert(entity);
            var readEntity = this.dataService.Get(entity.Id);

            // Assert
            readEntity.ShouldNotBeNull();
            readEntity.Id.ShouldBe(entity.Id);
            readEntity.Name.ShouldBe(entity.Name);
        }
Beispiel #29
0
        public void WhenSettingEntityFlexibleDataWithSchemaItShouldSetItIfDataIsValid()
        {
            const string schema = @"{
              'type': 'object',
              'properties': {
                'shoe_size': { 'type': 'number', 'minimum': 5, 'maximum': 12, 'multipleOf': 1.0 }
              }
            }";

            var entityMock = new EntityMock
            {
                ExtensionDataJsonSchema = schema,
                ["role"] = 10
            };

            entityMock["role"].Should().Be(10);
        }
Beispiel #30
0
        public void LiteDbDataService_Can_Delete_Entity()
        {
            // Set up
            var entity = new EntityMock {
                Name = Randomize.String()
            };

            this.dataService.Insert(entity);

            // Act
            this.dataService.Delete(entity);

            // Assert
            var deletedEntity = this.dataService.Get(entity.Id);

            deletedEntity.ShouldBeNull();
        }
 void before_each()
 {
     payByVoucherMock = RequestMocksFactory.CreateValidPayByVoucher();
 }
 void before_each()
 {
     wpfReconcileMock = RequestMocksFactory.CreateValidWpfReconcile();
 }
 void before_each()
 {
     singleReconcileMock = RequestMocksFactory.CreateValidSingleReconcile();
 }
Beispiel #34
0
		public void TryValidateObject_Throws_ValidationException_When_Property_Is_NullableAndRequired_And_Value_Is_Null ()
		{
			EntityMock entity = new EntityMock ();
			ICollection<ValidationResult> result = new List<ValidationResult> ();

			// Year = null
			bool isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A1-1");
			Assert.AreEqual (2, result.Count, "#A1-2");

			// Name = null, string
			result.Clear ();

			isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A2-1");
			Assert.AreEqual (2, result.Count, "#A2-2");

			// Name = string.Empty, string
			result.Clear ();

			entity.Name = String.Empty;
			isValid = Validator.TryValidateObject (entity, new ValidationContext (entity, null, null), result);

			Assert.IsFalse (isValid, "#A3-1");
			Assert.AreEqual (2, result.Count, "#A3-2");
		}
Beispiel #35
0
		public void TryValidateValue_Throws_ValidationException_When_Property_Is_NullableAndRequired_And_Value_Is_Null ()
		{
			EntityMock entity = new EntityMock ();
			ICollection<ValidationResult> result = new List<ValidationResult>();

			ICollection<ValidationAttribute> attributes = new List<ValidationAttribute> ();
			attributes.Add (new RequiredAttribute ());

			// Year = null
			bool isValid = Validator.TryValidateValue (null, new ValidationContext (entity, null, null) { MemberName = "Year" }, result, attributes);

			Assert.IsFalse (isValid, "#A1-1");
			Assert.AreEqual (1, result.Count, "#A1-2");

			// Name = null, string
			result.Clear ();

			isValid = Validator.TryValidateValue (null, new ValidationContext (entity, null, null) { MemberName =  "Name" }, result, attributes);

			Assert.IsFalse (isValid, "#A2-1");
			Assert.AreEqual (1, result.Count, "#A2-2");

			// Name = string.Empty, string
			result.Clear ();

			isValid = Validator.TryValidateValue (String.Empty, new ValidationContext (entity, null, null) { MemberName = "Name" }, result, attributes);

			Assert.IsFalse (isValid, "#A3-1");
			Assert.AreEqual (1, result.Count, "#A3-2");
		}
Beispiel #36
0
 void before_each()
 {
     payoutMock = RequestMocksFactory.CreateValidPayout();
 }
 void before_each()
 {
     captureMock = RequestMocksFactory.CreateValidCapture();
 }
Beispiel #38
0
 void before_each()
 {
     sofortMock = RequestMocksFactory.CreateValidSofort();
 }
 void before_each()
 {
     sale3dSyncMock = RequestMocksFactory.CreateValidSale3dSync();
 }
 void before_each()
 {
     multiRetrievalRequestMock = RequestMocksFactory.CreateValidMultiRetrievalRequest();
 }
 void before_each()
 {
     blacklistMock = RequestMocksFactory.CreateValidBlacklist();
 }
Beispiel #42
0
 void before_each()
 {
     cashUMock = RequestMocksFactory.CreateValidCashU();
 }
Beispiel #43
0
 void before_each()
 {
     creditMock = RequestMocksFactory.CreateValidCredit();
 }
Beispiel #44
0
 void before_each()
 {
     avsMock = RequestMocksFactory.CreateValidAvs();
 }
 void before_each()
 {
     paySafeCardMock = RequestMocksFactory.CreateValidPaySafeCard();
 }
 void before_each()
 {
     wpfCreateMock = RequestMocksFactory.CreateValidWpfCreate();
 }
 void before_each()
 {
     initRecurringSale3dSyncMock = RequestMocksFactory.CreateValidInitRecurringSale3dSync();
 }
 void before_each()
 {
     multiReconcile = RequestMocksFactory.CreateValidMultiReconcile();
 }
 void before_each()
 {
     multiChargebackMock = RequestMocksFactory.CreateValidMultiChargeback();
 }
 void before_each()
 {
     voidRequestMock = RequestMocksFactory.CreateValidVoidRequest();
 }
 void before_each()
 {
     authorize3dSyncMock = RequestMocksFactory.CreateValidAuthorize3dSync();
 }
Beispiel #52
0
 void before_each()
 {
     pproMock = RequestMocksFactory.CreateValidPpro();
 }