Esempio n. 1
0
        public void TestIfCompanyExistById()
        {
            var mockSet     = GenerateMock();
            var mockContext = new Mock <CompanyDBEntities>();

            mockContext.Setup(m => m.Companies).Returns(mockSet.Object);
            var companyContext = new CompanyDBContext(mockContext.Object);

            var comp     = companyContext.GetCompanyById(1);
            var findComp = companyContext.FindCompanyById(1);

            Assert.AreEqual(1, findComp.CompanyId);
            Assert.AreEqual(1, comp.Count);
            Assert.AreEqual(1, comp[0].CompanyId);
        }
Esempio n. 2
0
        public void TestIfDetailsUpdated()
        {
            var mockSet     = GenerateMock();
            var mockContext = new Mock <CompanyDBEntities>();

            mockContext.Setup(m => m.Companies).Returns(mockSet.Object);
            var companyContext = new CompanyDBContext(mockContext.Object);

            //Get a company by Id
            var firstComp = companyContext.FindCompanyById(1);

            firstComp.CompanyName = "Updated Company";

            //Get a list of companies
            var comp = companyContext.GetCompanyById(1);

            Assert.AreEqual("Updated Company", comp[0].CompanyName); //Updated data
        }