Example #1
0
        public async Task InsertDerivedEntityType()
        {
            await ResetDatasource();

            Uri serviceUrl = new Uri(this.BaseAddress + "/convention/");
            var client = new TypedProxy.Container(serviceUrl);
            client.Format.UseJson();

            TypedProxy.Manager manager = new TypedProxy.Manager { Id = 0, Heads = 1 };
            manager.Level = 2;
            manager.Gender = TypedProxy.Gender.Male;
            manager.PhoneNumbers = new List<string>() { "8621-9999-8888" };
            client.AddToEmployees(manager);
            client.SaveChanges();

            var employees = client.Employees.OfType<TypedProxy.Manager>().ToList();
            var insertedManager = employees.Where(m => m.Id == 3).Single();

            expectedValueOfNullableInt = 2;
            actualValueOfNullableInt = insertedManager.Level;
            Assert.True(expectedValueOfNullableInt == actualValueOfNullableInt,
                string.Format("Manager Level is in-correct, expected: {0}, actual: {1}", expectedValueOfNullableInt, actualValueOfNullableInt));
            TypedProxy.Gender? gender = manager.Gender;
            Assert.Equal(TypedProxy.Gender.Male, gender);
            expectedValueOfInt = 1;
            actualValueOfInt = manager.PhoneNumbers.Count();
            Assert.True(expectedValueOfInt == actualValueOfInt,
                string.Format("Manager PhoneNumbers count is in-correct, expected: {0}, actual: {1}", expectedValueOfInt, actualValueOfInt));
        }
Example #2
0
        public async Task InsertBaseEntity()
        {
            await ResetDatasource();

            Uri serviceUrl = new Uri(this.BaseAddress + "/AttributeRouting/");
            var client = new TypedProxy.Container(serviceUrl);
            client.Format.UseJson();
            string newName = "Name10";
            TypedProxy.Employee newEmployee = new TypedProxy.Employee() { Id = 0, Name = newName };
            client.AddToEmployees(newEmployee);
            client.SaveChanges();

            var insertedEmplyee = client.Employees.Where(e => e.Id >= 3).Single();
            expectedValueOfString = newName;
            actualValueOfString = insertedEmplyee.Name;

            Assert.True(expectedValueOfString == actualValueOfString,
               string.Format("Employee count is in-correct, expected: {0}, actual: {1}", expectedValueOfString, actualValueOfString));
        }