Exemplo n.º 1
0
        //[TestMethod]
        public async void TestDeleteAllAsync()
        {
            var motherService = new MotherService();
            var users         = await motherService.ListUserAsync();

            foreach (MotherLibrary.User user in users)
            {
                var tasks = await motherService.ListTaskAsync(user.UserName);

                foreach (MotherLibrary.Task task in tasks)
                {
                    await motherService.DeleteTaskAsync(user.UserName, task.Date, task.Begin);
                }
                await motherService.DeleteUserAsync(user.UserName);
            }
            var progresses = await motherService.ListProgressAsync();

            foreach (Progress progress in progresses)
            {
                await motherService.DeleteProgressAsync(progress.ProgressName);
            }

            users = await motherService.ListUserAsync();

            Assert.AreEqual(0, users.Count);
            var taskss = await motherService.ListTasksAsync();

            Assert.AreEqual(0, taskss.Count);
            progresses = await motherService.ListProgressAsync();

            Assert.AreEqual(0, progresses.Count);
        }
Exemplo n.º 2
0
        [TestMethod]          //Success
        public async Task TestProgressServicesAsync()
        {
            var motherService = new MotherService();                  //声明服务

            var progresses = await motherService.ListProgressAsync(); //初始时

            Assert.AreEqual(0, progresses.Count);

            var progress1 = new MotherLibrary.Progress {
                ProgressName = "TestProgress1", DefaultName = "Test1"
            };
            var progress2 = new MotherLibrary.Progress {
                ProgressName = "TestProgress2", DefaultName = "Test2"
            };
            var progress3 = new MotherLibrary.Progress {
                ProgressName = "TestProgress3", DefaultName = "Test3"
            };
            await motherService.NewProgressAsync(progress1.ProgressName, progress1.DefaultName); //插入3个测试进程

            await motherService.NewProgressAsync(progress2.ProgressName, progress2.DefaultName);

            await motherService.NewProgressAsync(progress3.ProgressName, progress3.DefaultName);


            progresses = await motherService.ListProgressAsync();

            Assert.AreEqual(3, progresses.Count);                       //应有3个进程

            Assert.AreEqual("TestProgress1", progresses[0].ProgressName);
            Assert.AreEqual("Test1", progresses[0].DefaultName);

            Assert.AreEqual("TestProgress2", progresses[1].ProgressName);
            Assert.AreEqual("Test2", progresses[1].DefaultName);

            Assert.AreEqual("TestProgress3", progresses[2].ProgressName);
            Assert.AreEqual("Test3", progresses[2].DefaultName);



            progresses[0].DefaultName = "test111";                 //修改进程数据
            progresses[1].DefaultName = "test222";
            progresses[2].DefaultName = "test333";

            await motherService.UpdateProgressAsync(progresses[0].ProgressName, progresses[0].DefaultName);

            await motherService.UpdateProgressAsync(progresses[1].ProgressName, progresses[1].DefaultName);

            await motherService.UpdateProgressAsync(progresses[2].ProgressName, progresses[2].DefaultName);


            progresses = await motherService.ListProgressAsync();       //确认修改的数据保存成功

            Assert.AreEqual("test111", progresses[0].DefaultName);
            Assert.AreEqual("test222", progresses[1].DefaultName);
            Assert.AreEqual("test333", progresses[2].DefaultName);



            Assert.AreEqual(3, progresses.Count);
            await motherService.DeleteProgressAsync(progresses[0].ProgressName);          //删除测试进程

            await motherService.DeleteProgressAsync(progresses[1].ProgressName);

            await motherService.DeleteProgressAsync(progresses[2].ProgressName);


            progresses = await motherService.ListProgressAsync();       //确认数量

            Assert.AreEqual(0, progresses.Count);
        }