コード例 #1
0
ファイル: AssemblerTest.cs プロジェクト: artemkv/darwin-web
        public void GetDTO_ObjectProp_Test()
        {
            var dataType = new ERModel.DataType()
            {
                Id       = new Guid("3FD6B018-C30A-470A-A4B5-0470366ACAB6"),
                TypeName = "INTEGER"
            };

            var attr = new ERModel.Attribute()
            {
                Id            = new Guid("1814BE78-4065-4F64-BD32-1A3FE588D3EA"),
                AttributeName = "FirstName",
                IsRequired    = true,

                DataType = dataType                 // !Important
            };

            var asm = new Assembler();

            RESTModel.Attribute dto = asm.GetDTO(attr) as RESTModel.Attribute;

            Assert.AreEqual(attr.Id, dto.Id);
            Assert.AreEqual(attr.AttributeName, dto.AttributeName);
            Assert.AreEqual(attr.IsRequired, dto.IsRequired);

            Assert.AreEqual(attr.DataType.Id, dto.DataTypeId);
        }
コード例 #2
0
ファイル: AssemblerTest.cs プロジェクト: artemkv/darwin-web
        public void GetDTO_ParentProp_Test()
        {
            var entity = new ERModel.Entity()
            {
                Id         = new Guid("A81DD7C9-3B6B-41D7-95E9-72ECEE645F05"),
                SchemaName = "dbo",
                EntityName = "Author"
            };

            var dataType = new ERModel.DataType()
            {
                Id       = new Guid("3FD6B018-C30A-470A-A4B5-0470366ACAB6"),
                TypeName = "INTEGER"
            };

            var attr = new ERModel.Attribute()
            {
                Id            = new Guid("1814BE78-4065-4F64-BD32-1A3FE588D3EA"),
                AttributeName = "FirstName",
                IsRequired    = true,
                DataType      = dataType,

                Entity = entity                 // !important
            };

            var asm = new Assembler();

            RESTModel.Attribute dto = asm.GetDTO(attr) as RESTModel.Attribute;

            Assert.AreEqual(attr.Id, dto.Id);
            Assert.AreEqual(attr.AttributeName, dto.AttributeName);
            Assert.AreEqual(attr.IsRequired, dto.IsRequired);

            Assert.AreEqual(attr.Entity.Id, dto.EntityId);
        }
コード例 #3
0
ファイル: AssemblerTest.cs プロジェクト: artemkv/darwin-web
        public void GetDTO_ObjectCollection_Test()
        {
            var dataType = new ERModel.DataType()
            {
                Id       = new Guid("3FD6B018-C30A-470A-A4B5-0470366ACAB6"),
                TypeName = "INTEGER"
            };

            var attr1 = new ERModel.Attribute()
            {
                Id            = new Guid("1814BE78-4065-4F64-BD32-1A3FE588D3EA"),
                AttributeName = "FirstName",
                IsRequired    = true,

                DataType = dataType
            };

            var attr2 = new ERModel.Attribute()
            {
                Id            = new Guid("1814BE78-4065-4F64-BD32-1A3FE588D3EA"),
                AttributeName = "LastName",
                IsRequired    = true,

                DataType = dataType
            };

            var entity = new ERModel.Entity()
            {
                Id         = new Guid("A81DD7C9-3B6B-41D7-95E9-72ECEE645F05"),
                SchemaName = "dbo",
                EntityName = "Author"
            };

            entity.Attributes.Add(attr1);
            entity.Attributes.Add(attr2);

            var asm = new Assembler();

            RESTModel.Entity dto = asm.GetDTO(entity) as RESTModel.Entity;

            Assert.AreEqual(entity.Id, dto.Id);

            Assert.AreEqual(entity.Attributes.Count, dto.Attributes.Count);

            Assert.AreEqual(entity.Attributes[0].Id, dto.Attributes[0].Id);
            Assert.AreEqual(entity.Attributes[0].AttributeName, dto.Attributes[0].AttributeName);
            Assert.AreEqual(entity.Attributes[0].IsRequired, dto.Attributes[0].IsRequired);

            Assert.AreEqual(entity.Attributes[1].Id, dto.Attributes[1].Id);
            Assert.AreEqual(entity.Attributes[1].AttributeName, dto.Attributes[1].AttributeName);
        }