public void shouldReturnWeightPrognosisXml() { AutoMappingsBootStrapper.MapHistoryGraphToAmChartData(); var user = new User("Min user"); var userContextMock = new Mock<IUserContext>(MockBehavior.Strict); userContextMock.Setup(x => x.User).Returns(user); var graphBuilderMock = new Mock<IGraphBuilder>(MockBehavior.Strict); ILine line = new Line(1, new Dictionary<DateTime, decimal> { { DateTime.Now.AddDays(1), 35M } }, "MyTitle"); var graph = new Graph { Labels = new[] { new Label { Value = "val1", Index = "1" } }, LinesContainer = new LinesContainer { Lines = new[] { line } } }; var userWeightBusinessLogicMock = new Mock<IUserWeightBusinessLogic>(); userWeightBusinessLogicMock.Setup(x => x.GetProjectionList(It.Is<User>(y => y == user))).Returns(line); graphBuilderMock.Setup(x => x.GetGraph(It.Is<ILine[]>(y => y[0] == line))).Returns(graph); var resultController = new CarbonFitness.App.Web.Controllers.ResultController(null, null, userContextMock.Object, graphBuilderMock.Object, userWeightBusinessLogicMock.Object, null); var result = resultController.ShowWeightPrognosisXml(); Assert.That(result.ObjectToSerialize, Is.AssignableTo(typeof(AmChartData))); var amChartData = (AmChartData) result.ObjectToSerialize; var dataPoints = amChartData.DataPoints; Assert.That(dataPoints, Is.Not.Null); var firstPoint = dataPoints.First(); Assert.That(firstPoint.Value, Is.EqualTo("val1")); Assert.That(amChartData.GraphRoot.Graphs[0].values[0].Value, Is.EqualTo("35")); userWeightBusinessLogicMock.Verify(); }
public void shouldHaveMultipleLines() { userContextMock.Setup(x => x.User).Returns(new User()); graphBuilderMock.Setup(x => x.GetGraph(It.Is<ILine[]>(y => y.Length == 2))).Returns(new Graph()); userIngredientBusinessLogicMock.Setup(x => x.GetNutrientHistory(It.IsAny<NutrientEntity>(), It.IsAny<User>())).Returns(new Line( new Dictionary<DateTime, decimal>{{DateTime.Now, 123}})); var resultController = new CarbonFitness.App.Web.Controllers.ResultController(userProfileBusinessLogic.Object, userIngredientBusinessLogicMock.Object, userContextMock.Object, graphBuilderMock.Object, null, null); NutrientEntity[] nutrients = new [] {NutrientEntity.ZincInmG, NutrientEntity.EVitaminInmG }; resultController.GetGraph(nutrients, false); userIngredientBusinessLogicMock.VerifyAll(); graphBuilderMock.VerifyAll(); }