public void AbundanceIndexDiagramUnexpectedErrorTest()
        {
            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.GetObservationsAbundanceIndexDiagramAsJSON(1, taxaIds[0]);

                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 AbundanceIndexDiagramSuccessTest()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                ResultController resultController = new ResultController();

                ShimControllerContextForLogin(true, resultController);

                var taxaIds = new ObservableCollection <int>
                {
                    Convert.ToInt32(TaxonId.DrumGrasshopper),
                    Convert.ToInt32(TaxonId.Butterflies)
                };

                SessionHandler.MySettings = new MySettings();
                SessionHandler.MySettings.Filter.Taxa.TaxonIds = taxaIds;
                SessionHandler.MySettings.Filter.Taxa.IsActive = true;

                // Act
                // Get Views and model
                var overViewResult = resultController.Diagrams();
                var overViewName   = overViewResult.ViewName;

                var viewResult = resultController.TimeSeriesDiagramOnSpeciesObservationAbundanceIndex() as ViewResult;
                var viewName   = viewResult.ViewName;

                // Get json result from server
                JsonNetResult diagramResult = resultController.GetObservationsAbundanceIndexDiagramAsJSON(1, taxaIds[0]);
                JsonModel     jsonResult    = (JsonModel)diagramResult.Data;
                List <KeyValuePair <string, object> > diagramListResult = (List <KeyValuePair <string, object> >)jsonResult.Data;

                // Assert
                Assert.IsNotNull(overViewResult);
                Assert.IsTrue(overViewName.Equals("Diagrams"));
                Assert.IsNotNull(viewResult);
                Assert.IsTrue(viewName.Equals("TimeSeriesDiagramOnSpeciesObservationAbundanceIndex"));

                Assert.IsNotNull(diagramResult);
                Assert.IsNotNull(jsonResult);
                Assert.IsTrue(jsonResult.Success);
                Assert.IsNotNull(diagramListResult);
                Assert.IsTrue(diagramListResult.Count > 0);
                Assert.IsNotNull(diagramListResult[0].Key);
                Assert.IsNotNull(diagramListResult[0].Value);
            }
        }
        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);
            }
        }