Esempio n. 1
0
        private DemographicFormData AddDemographicFormData(Form form)
        {
            var formData = new DemographicFormData()
            {
                Form        = form,
                DateOfBirth = new Question {
                    Caption = "Date Of Birth", DataType = QuestionDataType.Date, Form = form
                },
                Other = new Question {
                    Caption = "Other", DataType = QuestionDataType.String, Form = form
                },
                Race = new Question {
                    Caption = "Race", DataType = QuestionDataType.Enum, Form = form
                },
                Sex = new Question {
                    Caption = "Sex", DataType = QuestionDataType.Enum, Form = form
                }
            };

            DemographicFormDataRepository.Add(formData);
            QuestionRepository.Add(formData.DateOfBirth);
            QuestionRepository.Add(formData.Other);
            QuestionRepository.Add(formData.Race);
            QuestionRepository.Add(formData.Sex);
            return(formData);
        }
Esempio n. 2
0
        public void MappingTest()
        {
            //Arrange
            var dataStorage = new Mock <IDataStorage>();
            var entity      = new DemographicFormData()
            {
                Id          = 1,
                DateOfBirth = new Question {
                    Id = 2, Value = "2"
                },
                Other = new Question {
                    Id = 3, Value = "3"
                },
                Race = new Question {
                    Id = 4, Value = "4"
                },
                Sex = new Question {
                    Id = 5, Value = "5"
                }
            };
            var updatedEntity = new DemographicFormData()
            {
                Id          = 1,
                DateOfBirth = new Question {
                    Id = 2, Value = "2"
                },
                Other = new Question {
                    Id = 3, Value = "3"
                },
                Race = new Question {
                    Id = 4, Value = "4"
                },
                Sex = new Question {
                    Id = 5, Value = "5"
                }
            };
            var repository = new DemographicFormDataRepository(dataStorage.Object);

            dataStorage.Setup(ds => ds.GetData <DemographicFormData>()).Returns(new List <DemographicFormData> {
                entity
            });
            //Act
            repository.Edit(updatedEntity);
            //Assert
            //Values are equal
            Assert.That(entity.DateOfBirth.Value, Is.EqualTo(updatedEntity.DateOfBirth.Value));
            Assert.That(entity.Other.Value, Is.EqualTo(updatedEntity.Other.Value));
            Assert.That(entity.Race.Value, Is.EqualTo(updatedEntity.Race.Value));
            Assert.That(entity.Sex.Value, Is.EqualTo(updatedEntity.Sex.Value));

            //Objects are not equal
            Assert.That(entity.DateOfBirth, Is.Not.EqualTo(updatedEntity.DateOfBirth));
            Assert.That(entity.Other, Is.Not.EqualTo(updatedEntity.Other));
            Assert.That(entity.Race, Is.Not.EqualTo(updatedEntity.Race));
            Assert.That(entity.Sex, Is.Not.EqualTo(updatedEntity.Sex));
        }
        public void MappingTest()
        {
            //Arrange
            var dataStorage = new Mock<IDataStorage>();
            var entity = new DemographicFormData() {
                Id = 1,
                DateOfBirth = new Question {Id = 2, Value = "2"},
                Other = new Question {Id = 3, Value = "3"},
                Race = new Question {Id = 4, Value = "4"},
                Sex = new Question {Id = 5, Value = "5"}
            };
            var updatedEntity = new DemographicFormData() {
                Id = 1,
                DateOfBirth = new Question {Id = 2, Value = "2"},
                Other = new Question {Id = 3, Value = "3"},
                Race = new Question {Id = 4, Value = "4"},
                Sex = new Question {Id = 5, Value = "5"}
            };
            var repository = new DemographicFormDataRepository(dataStorage.Object);

            dataStorage.Setup(ds => ds.GetData<DemographicFormData>()).Returns(new List<DemographicFormData> {entity});
            //Act
            repository.Edit(updatedEntity);
            //Assert
            //Values are equal
            Assert.That(entity.DateOfBirth.Value, Is.EqualTo(updatedEntity.DateOfBirth.Value));
            Assert.That(entity.Other.Value, Is.EqualTo(updatedEntity.Other.Value));
            Assert.That(entity.Race.Value, Is.EqualTo(updatedEntity.Race.Value));
            Assert.That(entity.Sex.Value, Is.EqualTo(updatedEntity.Sex.Value));

            //Objects are not equal
            Assert.That(entity.DateOfBirth, Is.Not.EqualTo(updatedEntity.DateOfBirth));
            Assert.That(entity.Other, Is.Not.EqualTo(updatedEntity.Other));
            Assert.That(entity.Race, Is.Not.EqualTo(updatedEntity.Race));
            Assert.That(entity.Sex, Is.Not.EqualTo(updatedEntity.Sex));
        }