Exemple #1
0
        public void CreateMemento_AddAState_StateAdded()
        {
            var record = new MedicalRecord() { Rtf = "1", Tag = new Tag() { Category = TagCategory.Doctor } };
            var memento = new MedicalRecordMemento();

            Assert.AreEqual(0, record.PreviousStates.Count);
            memento.SaveState(record);
            Assert.AreEqual(1, record.PreviousStates.Count);
            Assert.AreEqual("1", record.PreviousStates[0].Rtf);
        }
Exemple #2
0
        public void CreateMemento_AddMoreThan10Items_10ItemsAreSaved()
        {
            var record = new MedicalRecord() { Rtf = "1" };
            var memento = new MedicalRecordMemento();

            for (int i = 0; i < 150; i++)
            {
                record.Rtf = (i + 1).ToString();
                memento.SaveState(record);
            }

            Assert.AreEqual(50, record.PreviousStates.Count);
            Assert.AreNotEqual("1", record.PreviousStates[0].Rtf);
        }
Exemple #3
0
        public void MapEntityToDto_MapMedicalRecordToMedicalRecordDto_MappingOccured()
        {
            var record = new MedicalRecord()
            {
                CreationDate = DateTime.Now.AddDays(-10),
                LastUpdate = DateTime.Now,
                Name = GetRandom.String,
                Rtf = GetRandom.String,
                Tag = this.RandomTag,
            };

            var mapped = Mapper.Map<MedicalRecord, MedicalRecordDto>(record);

            Assert.AreEqual(record.CreationDate, mapped.CreationDate);
            Assert.AreEqual(record.Id, mapped.Id);
            Assert.AreEqual(record.LastUpdate, mapped.LastUpdate);
            Assert.AreEqual(record.Name, mapped.Name);
            Assert.AreEqual(record.Rtf, mapped.Rtf);
            Assert.AreEqual(record.Tag.Category, mapped.Tag.Category);
            Assert.AreEqual(record.Tag.Name, mapped.Tag.Name);
            Assert.AreEqual(record.Tag.Notes, mapped.Tag.Notes);
        }