public void MappingTest()
        {
            //Arrange
            var dataStorage = new Mock<IDataStorage>();
            var entity = new ElectrocardiogramFormData() {
                Id = 1,
                ElectrocardiogramActualTime = new Question {Id = 2, Value = "2"},
                ElectrocardiogramAttachment = new Question {Id = 3, Value = "3"}
            };
            var updatedEntity = new ElectrocardiogramFormData() {
                Id = 1,
                ElectrocardiogramActualTime = new Question {Id = 3, Value = "3"},
                ElectrocardiogramAttachment = new Question {Id = 4, Value = "4"}
            };
            var repository = new ElectrocardiogramFormDataRepository(dataStorage.Object);

            dataStorage.Setup(ds => ds.GetData<ElectrocardiogramFormData>()).Returns(new List<ElectrocardiogramFormData> {entity});
            //Act
            repository.Edit(updatedEntity);
            //Assert
            //Values are equal
            Assert.That(entity.ElectrocardiogramActualTime.Value, Is.EqualTo(updatedEntity.ElectrocardiogramActualTime.Value));
            Assert.That(entity.ElectrocardiogramAttachment.Value, Is.EqualTo(updatedEntity.ElectrocardiogramAttachment.Value));

            //Objects are not equal
            Assert.That(entity.ElectrocardiogramActualTime, Is.Not.EqualTo(updatedEntity.ElectrocardiogramActualTime));
            Assert.That(entity.ElectrocardiogramAttachment, Is.Not.EqualTo(updatedEntity.ElectrocardiogramAttachment));
        }
示例#2
0
        private ElectrocardiogramFormData AddElectrocardiogramFormData(Form form)
        {
            var formData = new ElectrocardiogramFormData()
            {
                Form = form,
                ElectrocardiogramActualTime = new Question {
                    Caption = "Actual Time", DataType = QuestionDataType.Date, Form = form
                },
                ElectrocardiogramAttachment = new Question {
                    Caption = "Electrocardiogram Data File", DataType = QuestionDataType.Attachment, Form = form
                }
            };

            ElectrocardiogramFormDataRepository.Add(formData);
            QuestionRepository.Add(formData.ElectrocardiogramActualTime);
            QuestionRepository.Add(formData.ElectrocardiogramAttachment);
            return(formData);
        }
        public void MappingTest()
        {
            //Arrange
            var dataStorage = new Mock <IDataStorage>();
            var entity      = new ElectrocardiogramFormData()
            {
                Id = 1,
                ElectrocardiogramActualTime = new Question {
                    Id = 2, Value = "2"
                },
                ElectrocardiogramAttachment = new Question {
                    Id = 3, Value = "3"
                }
            };
            var updatedEntity = new ElectrocardiogramFormData()
            {
                Id = 1,
                ElectrocardiogramActualTime = new Question {
                    Id = 3, Value = "3"
                },
                ElectrocardiogramAttachment = new Question {
                    Id = 4, Value = "4"
                }
            };
            var repository = new ElectrocardiogramFormDataRepository(dataStorage.Object);

            dataStorage.Setup(ds => ds.GetData <ElectrocardiogramFormData>()).Returns(new List <ElectrocardiogramFormData> {
                entity
            });
            //Act
            repository.Edit(updatedEntity);
            //Assert
            //Values are equal
            Assert.That(entity.ElectrocardiogramActualTime.Value, Is.EqualTo(updatedEntity.ElectrocardiogramActualTime.Value));
            Assert.That(entity.ElectrocardiogramAttachment.Value, Is.EqualTo(updatedEntity.ElectrocardiogramAttachment.Value));

            //Objects are not equal
            Assert.That(entity.ElectrocardiogramActualTime, Is.Not.EqualTo(updatedEntity.ElectrocardiogramActualTime));
            Assert.That(entity.ElectrocardiogramAttachment, Is.Not.EqualTo(updatedEntity.ElectrocardiogramAttachment));
        }