public void DuplicateTest3() { using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { context.Set <Major>().Add(new Major { MajorCode = "111", MajorName = "222", MajorType = MajorTypeEnum.Optional }); context.SaveChanges(); } _majorvm = new MajorVM3(); _majorvm.DC = new DataContext(_seed, DBTypeEnum.Memory); _majorvm.MSD = new MockMSD(); _majorvm.Entity = new Major { MajorCode = "111", MajorName = "not222", MajorType = MajorTypeEnum.Required }; _majorvm.Validate(); Assert.IsTrue(_majorvm.MSD["Entity.MajorCode"].Count == 0); _majorvm.Entity = new Major { MajorCode = "not111", MajorName = "222", MajorType = MajorTypeEnum.Required }; _majorvm.Validate(); Assert.IsTrue(_majorvm.MSD["Entity.MajorName"].Count == 0); _majorvm.Entity = new Major { MajorCode = "111", MajorName = "222", MajorType = MajorTypeEnum.Required }; _majorvm.Validate(); Assert.IsTrue(_majorvm.MSD["Entity.MajorCode"].Count > 0); }