public void CreateExistingIndicatorTest() { var indicator = new Indicator { Area = 1, Red = new BinaryOperator(), Yellow = new BinaryOperator(), Green = new BinaryOperator(), }; var mock = new Mock <IRepository <Indicator> >(MockBehavior.Strict); mock.Setup(m => m.Add(It.IsAny <Indicator>())); mock.Setup(m => m.Has(indicator)).Returns(true); mock.Setup(m => m.Save()); IIndicatorLogic indicatorLogic = new IndicatorLogic(mock.Object); var result = indicatorLogic.AddIndicator(indicator); mock.VerifyAll(); Assert.AreEqual(indicator.Name, result.Name); }
public void CreateIndicator() { IAreaLogic areaLogic = new AreaLogic(null); var area = areaLogic.GetAreaByID(1); var Left1 = new Operator { Type = 5, Text = "22/5/2018", Area = area.ID, }; var Right1 = new Operator { Type = 5, Text = "22/3/2018", Area = area.ID, }; var binaryRed = new BinaryOperator { Type = 4, Left = Left1, Right = Right1, Sign = "<=", Area = area.ID, }; var Left2 = new Operator { Type = 2, Text = "2", Area = area.ID, }; var Right2 = new Operator { Type = 2, Text = "3", Area = area.ID, }; var binaryGreenRight = new BinaryOperator { Type = 4, Left = Left2, Right = Right2, Sign = ">", Area = area.ID, }; var binaryGreen = new BinaryOperator { Type = 4, Left = binaryRed, Right = binaryGreenRight, Sign = "OR", Area = area.ID, }; var indicator = new Indicator { Area = area.ID, Name = "Prueba1", Green = binaryGreen, Red = binaryRed, Yellow = binaryRed, }; IIndicatorLogic indicatorLogic = new IndicatorLogic(null); var result = indicatorLogic.AddIndicator(indicator); Assert.AreEqual(indicator.Name, result.Name); }