public class TestContext where T : class { protected Mock<t> mockRepository; protected Mock<testentities> mockTestEntities; protected TestContext() { mockRepository = new Mock<t>(MockBehavior.Strict); mockTestEntities= new Mock<testentities>(MockBehavior.Strict); mockTestEntities.Setup(ase => ase.SaveChanges()).Returns(1); } public class PGRepositoryTest : TestContext<ipgrepository> { [TestInitialize] public void TestInitialize() { pgRepository = new PGRepository(mockTestEntities.Object); pgViewModel = new PGViewModel { ID = 1, Name = "PG Unit Test", DisplayName = "PG Unit Test", IsActive = true, }; sessionViewModel = pgViewModel; userContext = new UserContext { UserID = "XXXX" }; } [TestMethod] public void CreateTest() { var IdSet = new IDSet(); IdSet = pgRepository.Create(pgViewModel, sessionViewModel, userContext); PresentationGroupViewModel testPG = pgRepository.GetPresentationGroup(IdSet.ID); Assert.AreEqual(IdSet.ID, testPG.ID); } }</ipgrepository></testentities></t></testentities></t>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)