public void Queries_CorrectViewModel_Mapping()
            {
                //Arrange
                var qRepository = new Mock<IQueryRepository>();
                var controller = new AnalyticsController(null, null, null, null, null, qRepository.Object);

                var dto = GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", false);

                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List<QueryReportDto> {dto});

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;
                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List<QueriesAnalyticsViewModel>);
                var model = viewResultBase.Model as List<QueriesAnalyticsViewModel>;
                Assert.That(model.Count, Is.EqualTo(1));

                AssertQueriesAnalyticsViewModel(model[0], dto.ClinicName, dto.DoctorName, dto.FormType, dto.QuestionName, 1, 0);

                qRepository.Verify(r => r.GetQueriesReportData(), Times.Once());
            }
            public void Queries_ComplexTest()
            {
                //Arrange
                var qRepository = new Mock<IQueryRepository>();
                var controller = new AnalyticsController(null, null, null, null, null, qRepository.Object);

                var dtos = new List<QueryReportDto> {
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", true),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption", true),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption1", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Happiness, "QuestionCaption1", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Inventory, "QuestionCaption", false),
                    GetQueryReportDto("Clinic1", "Super", "Doctor", FormType.Demographics, "QuestionCaption", true),
                    GetQueryReportDto("Clinic1", "Super1", "Doctor1", FormType.Happiness, "QuestionCaption", false),
                    GetQueryReportDto("Clinic1", "Super1", "Doctor1", FormType.Happiness, "QuestionCaption", true),
                    GetQueryReportDto("Clinic2", "Super2", "Doctor2", FormType.Electrocardiogram, "QuestionCaption", true),
                    GetQueryReportDto("Clinic2", "Super3", "Doctor3", FormType.Vitals, "QuestionCaption", false)
                };

                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List<QueryReportDto>(dtos));

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;
                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List<QueriesAnalyticsViewModel>);
                var model = viewResultBase.Model as List<QueriesAnalyticsViewModel>;
                Assert.That(model.Count, Is.EqualTo(7));
                AssertQueriesAnalyticsViewModel(model[0], "Clinic1", "Super Doctor", FormType.Happiness, "QuestionCaption", 5, 2);
                AssertQueriesAnalyticsViewModel(model[1], "Clinic1", "Super Doctor", FormType.Happiness, "QuestionCaption1", 2, 0);
                AssertQueriesAnalyticsViewModel(model[2], "Clinic1", "Super Doctor", FormType.Inventory, "QuestionCaption", 1, 0);
                AssertQueriesAnalyticsViewModel(model[3], "Clinic1", "Super Doctor", FormType.Demographics, "QuestionCaption", 1, 1);
                AssertQueriesAnalyticsViewModel(model[4], "Clinic1", "Super1 Doctor1", FormType.Happiness, "QuestionCaption", 2, 1);
                AssertQueriesAnalyticsViewModel(model[5], "Clinic2", "Super2 Doctor2", FormType.Electrocardiogram, "QuestionCaption",
                                                1, 1);
                AssertQueriesAnalyticsViewModel(model[6], "Clinic2", "Super3 Doctor3", FormType.Vitals, "QuestionCaption", 1, 0);

                qRepository.Verify(r => r.GetQueriesReportData(), Times.Once());
            }
            public void Queries_CorrectViewModel()
            {
                //Arrange
                var qRepository = new Mock<IQueryRepository>();
                var controller = new AnalyticsController(null, null, null, null, null, qRepository.Object);
                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List<QueryReportDto>());

                EmulateControllerContext(controller, false);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;
                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.Model is List<QueriesAnalyticsViewModel>);
                var model = viewResultBase.Model as List<QueriesAnalyticsViewModel>;
                Assert.That(model.Count, Is.EqualTo(0));

                qRepository.Verify(r => r.GetQueriesReportData(), Times.Once());
            }
            public void QueriesAnalytics_View(bool async, string viewName)
            {
                //Arrange
                var qRepository = new Mock<IQueryRepository>();
                var controller = new AnalyticsController(null, null, null, null, null, qRepository.Object);
                qRepository.Setup(r => r.GetQueriesReportData()).Returns(new List<QueryReportDto>());

                EmulateControllerContext(controller, async);

                //Act
                var result = controller.Queries();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is ViewResultBase);
                var viewResultBase = result as ViewResultBase;
                Assert.That(viewResultBase.Model, Is.Not.Null);
                Assert.That(viewResultBase.ViewName, Is.EqualTo(viewName));
            }