public void GetOpenQueries()
        {
            //Arrange
            var dataStorage = new Mock<IDataStorage>();
            var clinic = new Clinic {Caption = "Clinic1"};
            var doctor1 = new User {FirstName = "DoctorFirst1", LastName = "DoctorLast1", Clinic = clinic};
            var doctor2 = new User {FirstName = "DoctorFirst2", LastName = "DoctorLast2", Clinic = clinic};
            var patient1 = new Patient {PatientNumber = 11, Doctor = doctor1};
            var patient2 = new Patient {PatientNumber = 12, Doctor = doctor2};
            var visit1 = new Visit {Caption = "Visit1", Patient = patient1};
            var visit2 = new Visit {Caption = "Visit2", Patient = patient2};
            var form1 = new Form {FormType = FormType.Happiness, Visit = visit1};
            var form2 = new Form {FormType = FormType.Demographics, Visit = visit2};
            var question1 = new Question {Form = form1};
            var question2 = new Question {Form = form2};
            var query1 = new Query {Id = 1, QueryText = "Text1", Question = question1};
            var query2 = new Query {Id = 2, QueryText = "Text2", AnswerText = "Answer1", Question = question2};

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

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

            //Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Count(), Is.EqualTo(1));
            var query = result.ToList()[0];
            Assert.That(query.FormType, Is.EqualTo(FormType.Happiness));
            Assert.That(query.ClinicName, Is.EqualTo("Clinic1"));
            Assert.That(query.DoctorName, Is.EqualTo("DoctorLast1"));
            Assert.That(query.QuestionText, Is.EqualTo("Text1"));
            Assert.That(query.PatientNumber, Is.EqualTo(11));
            Assert.That(query.VisitName, Is.EqualTo("Visit1"));
        }
예제 #2
0
        public void GetOpenQueries()
        {
            //Arrange
            var dataStorage = new Mock <IDataStorage>();
            var clinic      = new Clinic {
                Caption = "Clinic1"
            };
            var doctor1 = new User {
                FirstName = "DoctorFirst1", LastName = "DoctorLast1", Clinic = clinic
            };
            var doctor2 = new User {
                FirstName = "DoctorFirst2", LastName = "DoctorLast2", Clinic = clinic
            };
            var patient1 = new Patient {
                PatientNumber = 11, Doctor = doctor1
            };
            var patient2 = new Patient {
                PatientNumber = 12, Doctor = doctor2
            };
            var visit1 = new Visit {
                Caption = "Visit1", Patient = patient1
            };
            var visit2 = new Visit {
                Caption = "Visit2", Patient = patient2
            };
            var form1 = new Form {
                FormType = FormType.Happiness, Visit = visit1
            };
            var form2 = new Form {
                FormType = FormType.Demographics, Visit = visit2
            };
            var question1 = new Question {
                Form = form1
            };
            var question2 = new Question {
                Form = form2
            };
            var query1 = new Query {
                Id = 1, QueryText = "Text1", Question = question1
            };
            var query2 = new Query {
                Id = 2, QueryText = "Text2", AnswerText = "Answer1", Question = question2
            };


            var repository = new QueryRepository(dataStorage.Object);

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

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

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

            Assert.That(query.FormType, Is.EqualTo(FormType.Happiness));
            Assert.That(query.ClinicName, Is.EqualTo("Clinic1"));
            Assert.That(query.DoctorName, Is.EqualTo("DoctorLast1"));
            Assert.That(query.QuestionText, Is.EqualTo("Text1"));
            Assert.That(query.PatientNumber, Is.EqualTo(11));
            Assert.That(query.VisitName, Is.EqualTo("Visit1"));
        }