Exemplo n.º 1
0
        public void Given_body_part_is_in_list_when_AddBodyPart_then_body_part_is_not_duplicated()
        {
            //given
            var bodyPart = new BodyPart() { Id = 3425, Description = "Finger nail" };

            var target = new AccidentRecord();

            target.AddBodyPartThatWasInjured(bodyPart, null);
            target.AddBodyPartThatWasInjured(bodyPart, null);

            Assert.AreEqual(1, target.AccidentRecordBodyParts.Count);
        }
        public void Given_bodypart_is_in_list_when_RemoveInjury_then_Injury_removed_from_list()
        {
            //given
            var bodypart = new BodyPart() { Id = 3425, Description = "Anterior cruciate ligament", Deleted = false};
            var bodypart2 = new BodyPart() { Id = 123124, Description = "Hip flexior", Deleted = false };

            var target = new AccidentRecord();

            target.AddBodyPartThatWasInjured(bodypart, null);
            target.AddBodyPartThatWasInjured(bodypart2, null);

            //when
            target.RemoveBodyPartThatWasInjured(bodypart2, null);

            Assert.AreEqual(1, target.AccidentRecordBodyParts.Count);
            Assert.IsTrue(target.AccidentRecordBodyParts.All(x => x.BodyPart.Id != bodypart2.Id));
        }
        public void Given_bodypart_is_not_in_list_when_RemoveInjury_then_Injury_list_remains_the_same()
        {
            //given
            var bodypart = new BodyPart() { Id = 3425, Description = "Anterior cruciate ligament" };
            var bodypart2 = new BodyPart() { Id = 123124, Description = "Hip flexior" };

            var target = new AccidentRecord();

            target.AddBodyPartThatWasInjured(bodypart, null);
            target.AddBodyPartThatWasInjured(bodypart2, null);

            //when
            target.RemoveBodyPartThatWasInjured(new BodyPart() { Id = 124314, Description = "Test" }, null);


            Assert.AreEqual(2, target.AccidentRecordBodyParts.Count);
        }
Exemplo n.º 4
0
        public void Given_body_part_list_is_empty_when_AddBodyPart_then_body_part_appears_in_list()
        {
            //given
            var bodyPart = new BodyPart() { Id = 3425, Description = "Toe nail" };

            var target = new AccidentRecord();

            target.AddBodyPartThatWasInjured(bodyPart, null);

            Assert.IsTrue(target.AccidentRecordBodyParts.Any(x => x.BodyPart.Id == bodyPart.Id));

            Assert.AreEqual(target, target.AccidentRecordBodyParts.First(x => x.BodyPart.Id == bodyPart.Id));
        }