예제 #1
0
        public void Mapping_Property_Assign_To_DataRow()
        {
            // Source
            var source = new MockPerson()
            {
                Name = "NCsoft 1", Age = 11
            };

            // Target
            var target = new DataTable();

            target.Columns.Add("Name", typeof(string));
            target.Columns.Add("Age", typeof(int));

            var mapping1 = new MappingProviderForProperty(source);
            var mapping2 = new MappingProviderForDataRow(target);

            mapping1.AssignTo(mapping2);

            var row = target.Rows[0];

            TestContext.WriteLine("Name:{0}, Age:{1}", row["Name"], row["Age"]);

            Assert.AreEqual("NCsoft 1", row["Name"]);
            Assert.AreEqual(11, row["Age"]);
        }
예제 #2
0
        public void SetUp()
        {
            var _fakeDriver = new Driver("First", "Last", "Male", "Car");

            _fakePassenger = new MockPerson("Person", "Name", "Male");
            _bus           = new Bus(_fakeDriver, 100, 50, 2, 1);
        }
예제 #3
0
        public void Insertion()
        {
            const string mockAdress = "mock adress";
            const int mockAge = 51;
            const string mockName = "Zinedine Zidane";
            var person = new MockPerson() {Adress = mockAdress, Age = mockAge, Name = mockName};

            var hashTable = new NaiveHashTable<MockPerson>();
            var retrievedZizou = hashTable["zizou"] = person;
            Assert.AreEqual(mockName, retrievedZizou.Name,"#Z01");
            Assert.AreEqual(mockAge, retrievedZizou.Age, "#Z02");
            Assert.AreEqual(mockAdress, retrievedZizou.Adress, "#Z03");

            bool isSuccess = false;
            try
            {
                var person2 = new MockPerson();
                hashTable["zizou"] = person2;
            }
            catch (ArgumentException)
            {

                isSuccess = true;
            }
            Assert.IsTrue(isSuccess, "Exception should have been raised.");
        }
        public override IPerson GetPerson(params ICardType[][] cardTypesList)
        {
            var mockPerson = new MockPerson();

            foreach (var cardTypes in cardTypesList)
            {
                var wallet = WalletFactory.GetWallet(cardTypes);
                mockPerson.Wallets.Add(wallet);
            }

            return(mockPerson);
        }
        public async Task <MockPerson> CreatePerson(MockPerson person)
        {
            var relativeUrl = "PersonManagement/Persons";

            try
            {
                person = await PostAndReturnCreatedObjectAsync(relativeUrl, person);

                return(person);
            }
            catch (Exception)
            {
                return(null);
            }
        }
예제 #6
0
        public void MappingProperty()
        {
            var person = new MockPerson() { Name = "NCsoft 1", Age = 11 };

            var mapping = new MappingProviderForProperty(person);

            mapping.Setter("Name", "Junil, Um");
            mapping.Setter("Age", 255);
            var obj1 = mapping.Getter("Name");

            Console.WriteLine(obj1);
            Console.WriteLine(person.Name);

            Assert.AreEqual("Junil, Um", mapping.Getter("Name"));
            Assert.AreEqual(255, mapping.Getter("Age"));
        }
예제 #7
0
        public void Mapping_DataRow_Assign_To_Property()
        {
            var source = new DataTable();
            source.Columns.Add("Name", typeof(string));
            source.Columns.Add("Age", typeof(int));
            source.Rows.Add("NCsoft 1", 11);

            var target = new MockPerson();

            var mapping1 = new MappingProviderForDataRow(source.Rows[0]);
            var mapping2 = new MappingProviderForProperty(target);
            mapping1.AssignTo(mapping2);

            TestContext.WriteLine("Name:{0}, Age:{1}", target.Name, target.Age);

            Assert.AreEqual("NCsoft 1", target.Name);
            Assert.AreEqual(11, target.Age);
        }
예제 #8
0
        public void MappingProperty()
        {
            var person = new MockPerson()
            {
                Name = "NCsoft 1", Age = 11
            };

            var mapping = new MappingProviderForProperty(person);

            mapping.Setter("Name", "Junil, Um");
            mapping.Setter("Age", 255);
            var obj1 = mapping.Getter("Name");

            Console.WriteLine(obj1);
            Console.WriteLine(person.Name);

            Assert.AreEqual("Junil, Um", mapping.Getter("Name"));
            Assert.AreEqual(255, mapping.Getter("Age"));
        }
예제 #9
0
        public void Mapping_DataRow_Assign_To_Property()
        {
            var source = new DataTable();

            source.Columns.Add("Name", typeof(string));
            source.Columns.Add("Age", typeof(int));
            source.Rows.Add("NCsoft 1", 11);

            var target = new MockPerson();

            var mapping1 = new MappingProviderForDataRow(source.Rows[0]);
            var mapping2 = new MappingProviderForProperty(target);

            mapping1.AssignTo(mapping2);

            TestContext.WriteLine("Name:{0}, Age:{1}", target.Name, target.Age);

            Assert.AreEqual("NCsoft 1", target.Name);
            Assert.AreEqual(11, target.Age);
        }
예제 #10
0
        public void Mapping_Property_Assign_To_DataRow()
        {
            // Source
            var source = new MockPerson() { Name = "NCsoft 1", Age = 11 };

            // Target
            var target = new DataTable();
            target.Columns.Add("Name", typeof(string));
            target.Columns.Add("Age", typeof(int));

            var mapping1 = new MappingProviderForProperty(source);
            var mapping2 = new MappingProviderForDataRow(target);

            mapping1.AssignTo(mapping2);

            var row = target.Rows[0];
            TestContext.WriteLine("Name:{0}, Age:{1}", row["Name"], row["Age"]);

            Assert.AreEqual("NCsoft 1", row["Name"]);
            Assert.AreEqual(11, row["Age"]);
        }