Exemple #1
0
        public void CharacterMapper_MapNoteToNoteCM_ValidCall()
        {
            //Arrange
            var record = CreateTestData.GetSampleNote();
            var actual = new NoteCM();

            //Act
            actual = CharacterMapper.mapNoteToNoteCM(record);

            actual.Should().BeEquivalentTo(record,
                                           options => options.Excluding(o => o.Character_id));
        }
Exemple #2
0
        public IEnumerable <NoteCM> buildNoteCMsFOrCharacter(Guid Character_id)
        {
            List <Note>   foundNotes = _userAccess.GetNotesOwnedBy(Character_id).ToList();
            List <NoteCM> CMs        = new List <NoteCM>();

            int i = 0;

            foreach (Note note in foundNotes)
            {
                NoteCM cm = CharacterMapper.mapNoteToNoteCM(note);
                cm.Index = i;
                i++;
                CMs.Add(cm);
            }
            return(CMs);
        }
Exemple #3
0
        public void CMBuilder_buildNoteCMsForCharacter_ValidCall()
        {
            List <Note> notes   = CreateTestData.GetListOfNotes();
            var         mockSet = new Mock <DbSet <Note> >()
                                  .SetupData(notes, o =>
            {
                return(notes.Single(x => x.Character_id.CompareTo(o.First()) == 0));
            });
            Guid          Grog_id  = Guid.Parse("11111111-2222-3333-4444-555555555555");
            List <NoteCM> expected = new List <NoteCM>();


            Guid   Spelling_id  = Guid.Parse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee");
            Note   spellingNote = notes.Find(x => x.Note_id == Spelling_id);
            NoteCM spellingCM   = CharacterMapper.mapNoteToNoteCM(spellingNote);

            spellingCM.Index = 0;
            expected.Add(spellingCM);

            Guid   GreatAxe_id  = Guid.Parse("361bd911-0702-437f-ab59-a29da0f9fba4");
            Note   GreatAxeNote = notes.Find(x => x.Note_id == GreatAxe_id);
            NoteCM greatAxeCM   = CharacterMapper.mapNoteToNoteCM(GreatAxeNote);

            greatAxeCM.Index = 1;
            expected.Add(greatAxeCM);

            using (var mockContext = AutoMock.GetLoose())
            {
                mockContext.Mock <CharacterContext>()
                .Setup(x => x.Set <Note>()).Returns(mockSet.Object);
                mockContext.Mock <CharacterContext>()
                .Setup(x => x.Notes).Returns(mockSet.Object);

                IUnitOfWork     uow    = UoW_Factory.getUnitofWork(mockContext);
                IBaseUserAccess access = UserAccessFactory.getBaseUserAccess(uow);

                //Act
                ICharacterCMBuilder toTest = ProcessorFactory.GetCharacterCMBuilder(access);
                var actual = toTest.buildNoteCMsFOrCharacter(Grog_id);

                //Assert
                actual.Should().BeEquivalentTo(expected);
            }
        }