示例#1
0
        public void getAllIndicatorsOK2()
        {
            var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            var           id         = Guid.NewGuid();
            var           id2        = Guid.NewGuid();
            string        color      = "red";
            BaseCondition component  = new Condition();
            Indicator     indicator  = new Indicator();
            Indicator     indicator2 = new Indicator();

            indicator.Id        = id;
            indicator.Color     = color;
            indicator.Condition = component;
            indicatorRepo.Add(indicator);
            indicatorRepo.Save();
            indicator2.Id        = id2;
            indicator2.Color     = color;
            indicator2.Condition = component;
            indicatorRepo.Add(indicator2);
            indicatorRepo.Save();
            List <Indicator> indicators = indicatorRepo.GetAll().ToList();

            Assert.IsTrue(indicators[0].Id == id && indicators[1].Id == id2);
        }
示例#2
0
        public void RemoveIndicatorOK()
        {
            var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            var           id        = Guid.NewGuid();
            string        color     = "red";
            BaseCondition component = new Condition();
            Indicator     indicator = new Indicator();

            indicator.Id        = id;
            indicator.Color     = color;
            indicator.Condition = component;
            indicatorRepo.Add(indicator);
            indicatorRepo.Save();
            indicatorRepo.Remove(indicator);
            indicatorRepo.Save();
            var indicators = indicatorRepo.GetAll().ToList();

            Assert.AreEqual(indicators.Count, 0);
        }
示例#3
0
        public void AddIndicatorWithSameId()
        {
            var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            var           id         = Guid.NewGuid();
            string        color      = "red";
            BaseCondition component  = new Condition();
            Indicator     indicator  = new Indicator();
            Indicator     indicator2 = new Indicator();

            indicator.Id        = id;
            indicator.Color     = color;
            indicator.Condition = component;
            indicatorRepo.Add(indicator);
            indicatorRepo.Save();
            indicator2.Id        = id;
            indicator2.Color     = color;
            indicator2.Condition = component;
            indicatorRepo.Add(indicator2);
            indicatorRepo.Save();
        }
示例#4
0
        public void RemoveIndicatorNotExist()
        {
            var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            var           id        = Guid.NewGuid();
            string        color     = "red";
            BaseCondition component = new Condition();
            Indicator     indicator = new Indicator();

            indicator.Id        = id;
            indicator.Color     = color;
            indicator.Condition = component;
            indicatorRepo.Remove(indicator);
            indicatorRepo.Save();
        }
示例#5
0
        public void GetIndicatorByIdOK()
        {
            string contextName = Guid.NewGuid().ToString();
            var    context     = ContextFactory.GetMemoryContext(contextName);
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            var           id        = Guid.NewGuid();
            string        color     = "red";
            BaseCondition component = new Condition();
            Indicator     indicator = new Indicator();

            indicator.Id        = id;
            indicator.Color     = color;
            indicator.Condition = component;
            indicatorRepo.Add(indicator);
            indicatorRepo.Save();

            context       = ContextFactory.GetMemoryContext(contextName);
            indicatorRepo = new IndicatorRepository(context);
            Indicator obtainedIndicator = indicatorRepo.Get(id);

            Assert.AreEqual(obtainedIndicator.Id, indicator.Id);
        }
示例#6
0
        public void AddIndicatorOK()
        {
            var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString());
            IRepository <Indicator> indicatorRepo = new IndicatorRepository(context);
            BaseCondition           condition1    = new Condition();
            BaseCondition           condition2    = new Condition();
            BaseCondition           condition3    = new Condition();


            Indicator indicator = new Indicator()
            {
                Name            = "Indicator 1",
                Id              = Guid.NewGuid(),
                GreenCondition  = condition1,
                YellowCondition = condition2,
                RedCondition    = condition3
            };

            indicatorRepo.Add(indicator);
            indicatorRepo.Save();
            var indicators = indicatorRepo.GetAll().ToList();

            Assert.AreEqual(indicators[0].Name, indicator.Name);
        }