public void DiagramUnexpectedErrorTest() { using (ShimsContext.Create()) { // Arrange ResultController resultController = new ResultController(); ShimControllerContextForLogin(true, resultController); var taxaIds = new ObservableCollection <int> { 100573 }; SessionHandler.MySettings = new MySettings(); SessionHandler.MySettings.Filter.Taxa.TaxonIds = taxaIds; SessionHandler.MySettings.Filter.Taxa.IsActive = true; SessionHandler.MySettings.Presentation.Table.IsActive = true; // Act var result = resultController.Diagrams(); MakeGetCurrentUserFunctionCallThrowException(); var obsResult = resultController.GetObservationsDiagramAsJSON(1); JsonModel jsonResult = (JsonModel)obsResult.Data; // Assert Assert.IsNotNull(obsResult); Assert.IsNotNull(result); Assert.IsFalse(jsonResult.Success); Assert.IsNull(jsonResult.Data); Assert.AreEqual("Login to UserService or other service failed.", jsonResult.Msg); } }
public void DiagramSuccessTest() { using (ShimsContext.Create()) { // Arrange ResultController resultController = new ResultController(); ShimControllerContextForLogin(true, resultController); var taxaIds = new ObservableCollection <int> { 100573 }; SessionHandler.MySettings = new MySettings(); SessionHandler.MySettings.Filter.Taxa.TaxonIds = taxaIds; SessionHandler.MySettings.Filter.Taxa.IsActive = true; // IUserContext context = SessionHandler.UserContext; // Act // Get Views and model var overViewResult = resultController.Diagrams(); var overViewName = overViewResult.ViewName; var viewResult = resultController.TimeSeriesHistogramOnSpeciesObservationCounts(); var viewName = viewResult.ViewName; // Get json result from server JsonNetResult diagramResult = resultController.GetObservationsDiagramAsJSON(1); JsonModel jsonResult = (JsonModel)diagramResult.Data; List <KeyValuePair <string, Int64> > diagramListResult = (List <KeyValuePair <string, Int64> >)jsonResult.Data; // Assert Assert.IsNotNull(overViewResult); Assert.IsTrue(overViewName.Equals("Diagrams")); Assert.IsNotNull(viewResult); Assert.IsTrue(viewName.Equals("TimeSeriesHistogramOnSpeciesObservationCounts")); Assert.IsNotNull(diagramResult); Assert.IsNotNull(jsonResult); Assert.IsTrue(jsonResult.Success); Assert.IsNotNull(diagramListResult); Assert.IsTrue(diagramListResult.Count > 0); Assert.IsNotNull(diagramListResult[0].Key); Assert.IsTrue(diagramListResult[0].Value > 0); } }
public void DiagramNoTaxaSelectedTest() { ResultController resultController; JsonNetResult result; JsonModel jsonResult; List <KeyValuePair <string, Int64> > diagramResult; resultController = new ResultController(); SessionHandler.MySettings.Filter.Taxa.TaxonIds = new ObservableCollection <int>(); result = resultController.GetObservationsDiagramAsJSON(1); jsonResult = (JsonModel)result.Data; diagramResult = jsonResult.Data as List <KeyValuePair <string, Int64> >; Assert.IsTrue(jsonResult.Success); Assert.IsNotNull(jsonResult.Data); Assert.IsNotNull(diagramResult); Assert.IsTrue(diagramResult.Count > 0); }