Esempio n. 1
0
        public void TestCrudService()
        {
            int    expectedId = 2;
            string readId     = "Adan";
            string updateId   = "Sonny";

            MockStorage ms = new MockStorage();
            CrudService cs = new CrudService(ms);

            cs.Create("Adan"); //Adding to NameList
            cs.Create("Jae");
            cs.Create("Tiana");
            cs.Delete("test"); //Deleting from NameList


            Assert.AreEqual(expectedId, ms.NameList.Count);                                   // compare 2 to the Namelist count
            Assert.AreEqual(readId, ms.Select());                                             //comparing Adan to value in Select function
            Assert.AreEqual(expectedId, ms.Update(readId, updateId));                         // updating Adan to Sonny
            Assert.AreEqual(updateId, ms.NameList.Where(n => n == "Sonny").FirstOrDefault()); //Checking to if Sonny exist in NameList
        }
Esempio n. 2
0
        public void TestCrudService()
        {
            int         expectedId     = 3;
            string      expectedString = "Tiana";
            string      newName        = "John";
            int         count          = 2;
            MockStorage ms             = new MockStorage();
            CrudService cs             = new CrudService(ms);

            cs.Create("Tiana");
            cs.Create("Adan");
            cs.Create("Britto");


            Assert.AreEqual(expectedString, ms.Read());

            Assert.AreEqual(expectedId, ms.Update(expectedString, newName));
            Assert.AreEqual(newName, ms.NameList.Where(n => n == "John").FirstOrDefault());

            cs.Delete("Britto");
            Assert.AreEqual(count, ms.NameList.Count);
        }