예제 #1
0
            public void CorrectModel()
            {
                //Arrange
                var dataStorage = new Mock <IDataStorage>();

                dataStorage.Setup(ds => ds.GetData <Query>()).Returns(new List <Query>());
                var repository = new QueryRepository(dataStorage.Object);

                //Act
                var result = repository.GetQueriesReportData();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is List <QueryReportDto>);
                Assert.That(result.Count(), Is.EqualTo(0));
            }
예제 #2
0
            public void CorrectModelMapping()
            {
                //Arrange
                var dataStorage = new Mock <IDataStorage>();
                var repository  = new QueryRepository(dataStorage.Object);

                var clinic = new Clinic {
                    Caption = "Clinic"
                };
                var doctor = new User {
                    FirstName = "DoctorFirst", LastName = "DoctorLast", Clinic = clinic
                };
                var patient = new Patient {
                    Doctor = doctor
                };
                var visit = new Visit {
                    Caption = "Visit", Patient = patient
                };
                var form1 = new Form {
                    FormType = FormType.Happiness, Visit = visit
                };
                var question1 = new Question {
                    Caption = "QuestionCaption1", Form = form1
                };
                var query1 = new Query {
                    Id = 1, Question = question1
                };

                var form2 = new Form {
                    FormType = FormType.Inventory, Visit = visit
                };
                var question2 = new Question {
                    Caption = "QuestionCaption2", Form = form2
                };
                var query2 = new Query {
                    Id = 2, Question = question2, AnswerText = "Answer"
                };

                dataStorage.Setup(ds => ds.GetData <Query>()).Returns(new List <Query> {
                    query1, query2
                });

                //Act
                var result = repository.GetQueriesReportData();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.EqualTo(2));
                var dto = result.ToList()[0];

                Assert.That(dto.FormType, Is.EqualTo(FormType.Happiness));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption1"));
                Assert.That(dto.IsOpen, Is.True);

                dto = result.ToList()[1];
                Assert.That(dto.FormType, Is.EqualTo(FormType.Inventory));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption2"));
                Assert.That(dto.IsOpen, Is.False);
            }
            public void CorrectModelMapping()
            {
                //Arrange
                var dataStorage = new Mock<IDataStorage>();
                var repository = new QueryRepository(dataStorage.Object);

                var clinic = new Clinic {Caption = "Clinic"};
                var doctor = new User {FirstName = "DoctorFirst", LastName = "DoctorLast", Clinic = clinic};
                var patient = new Patient {Doctor = doctor};
                var visit = new Visit {Caption = "Visit", Patient = patient};
                var form1 = new Form {FormType = FormType.Happiness, Visit = visit};
                var question1 = new Question {Caption = "QuestionCaption1", Form = form1};
                var query1 = new Query {Id = 1, Question = question1};

                var form2 = new Form {FormType = FormType.Inventory, Visit = visit};
                var question2 = new Question {Caption = "QuestionCaption2", Form = form2};
                var query2 = new Query {Id = 2, Question = question2, AnswerText = "Answer"};

                dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query> {query1, query2});

                //Act
                var result = repository.GetQueriesReportData();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Count(), Is.EqualTo(2));
                var dto = result.ToList()[0];
                Assert.That(dto.FormType, Is.EqualTo(FormType.Happiness));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption1"));
                Assert.That(dto.IsOpen, Is.True);

                dto = result.ToList()[1];
                Assert.That(dto.FormType, Is.EqualTo(FormType.Inventory));
                Assert.That(dto.ClinicName, Is.EqualTo("Clinic"));
                Assert.That(dto.DoctorName, Is.EqualTo("DoctorFirst DoctorLast"));
                Assert.That(dto.QuestionName, Is.EqualTo("QuestionCaption2"));
                Assert.That(dto.IsOpen, Is.False);
            }
            public void CorrectModel()
            {
                //Arrange
                var dataStorage = new Mock<IDataStorage>();
                dataStorage.Setup(ds => ds.GetData<Query>()).Returns(new List<Query>());
                var repository = new QueryRepository(dataStorage.Object);

                //Act
                var result = repository.GetQueriesReportData();

                //Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result is List<QueryReportDto>);
                Assert.That(result.Count(), Is.EqualTo(0));
            }