public void TaskFailTest()
        {
            var task   = new ListServices(EmptyDbContext);
            var result = task.DoTask(null);

            Assert.IsFalse(result.Success);
            Assert.IsNotNull(result.Exception);
        }
        public void TaskSuccessTest()
        {
            var task   = new ListServices(DbContext);
            var result = task.DoTask(null);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNotNull(result.Data);
            Assert.IsTrue(result.Data.Any());

            foreach (var service in result.Data)
            {
                Assert.IsTrue(service.Name.Length > 0);
            }
        }
Exemplo n.º 3
0
        public void UpdatePlatformModel(Platform platform)
        {
            var listServicesTask = new ListServices(DbContext);
            var allServices      = listServicesTask.DoTask(null).Data;

            const int maxServiceCount  = 5;
            var       numberOfServices = new Random().Next(1, maxServiceCount);

            platform.Name     = nameof(Platform) + " " + DateTime.Now.Ticks;
            platform.Website  = "https://update.com";
            platform.Services = new List <Service>();
            for (var i = 0; i < numberOfServices; i++)
            {
                var randomIndex = new Random().Next(allServices.Count - 1);
                platform.Services.Add(allServices[randomIndex]);
            }
        }