Esempio n. 1
0
        public void CompareContactsWorksCorrectly()
        {
            // Arrange
            Contact oldContact = new Contact()
            {
                Id = 1, Name = "kontakt1", Address = new Address()
                {
                    City = "Nürnberg"
                }, ContactPossibilities =
                    new ContactPossibilities()
                {
                    Mail = "*****@*****.**"
                }
            };
            Contact newContact = new Contact()
            {
                Id      = oldContact.Id, Name = "kontakt2",
                Address = new Address()
                {
                    City = "Tübingen"
                }
            };

            // Act
            ComparerForModificationEntryCreation.CompareContacts(oldContact, newContact, null, true, out List <ModificationEntry> listWithNewEntries, out List <ModificationEntry> listWithDeletion, 0);

            //Assert
            Assert.Equal(3, listWithNewEntries.Count);
            Assert.Single(listWithDeletion);

            Assert.Equal(1, listWithNewEntries[0].DataModelId);
            Assert.Equal(MODEL_TYPE.CONTACT, listWithNewEntries[0].DataModelType);
            Assert.Equal(DATA_TYPE.NAME, listWithNewEntries[0].DataType);
            Assert.Equal("kontakt2", listWithNewEntries[0].ActualValue);

            Assert.Equal(1, listWithNewEntries[1].DataModelId);
            Assert.Equal(MODEL_TYPE.CONTACT, listWithNewEntries[1].DataModelType);
            Assert.Equal(DATA_TYPE.CITY, listWithNewEntries[1].DataType);
            Assert.Equal("Tübingen", listWithNewEntries[1].ActualValue);

            Assert.Equal(1, listWithDeletion[0].DataModelId);
            Assert.Equal(MODEL_TYPE.CONTACT, listWithDeletion[0].DataModelType);
            Assert.Equal(DATA_TYPE.MAIL, listWithDeletion[0].DataType);
        }
 public async Task UpdateContactAsync(User usernameOfModification, Contact oldContact, Contact newContact, bool deleteEntries)
 {
     await Task.Run(() => ComparerForModificationEntryCreation.CompareContacts(oldContact, newContact, usernameOfModification, deleteEntries, out listWithCreation, out listWithDeletion, contactPossEntriesRepo.GetTotalAmountOfEntities() + 1));
 }