Esempio n. 1
0
        public void Should_Create_New_Tasks()
        {
            //Prepare for test
            var initialTaskCount = UsingDbContext(context => context.Tasks.Count());

            //Run SUT
            AsyncHelper.RunSync(() => _taskAppService.CreateTaskAsync(
                                    new CreateTaskInput
            {
                Description = "service11"
            }));
            AsyncHelper.RunSync(() => _taskAppService.CreateTaskAsync(
                                    new CreateTaskInput
            {
                Description = "service22"
            }));

            //Check results
            UsingDbContext(context =>
            {
                context.Tasks.Count().ShouldBe(initialTaskCount + 2);
                context.Tasks.FirstOrDefault(t => t.Description == "service11").ShouldNotBe(null);
                var task2 = context.Tasks.FirstOrDefault(t => t.Description == "service22");
                task2.ShouldNotBe(null);
            });
        }
Esempio n. 2
0
        public void UpdateStoredTasks()
        {
            var services = ServiceController.GetServices();

            foreach (var service in services)
            {
                AsyncHelper.RunSync(
                    () =>
                    _taskAppService.CreateTaskAsync(new CreateTaskInput()
                {
                    Name        = service.ServiceName,
                    Description = service.DisplayName,
                    State       = service.Status == ServiceControllerStatus.Stopped ? TaskState.Stopped : TaskState.Active
                }));
            }
        }