public void shouldBeAbleToValidateAvegaIntranetLogin() {
			GoogleContactService googleContactService = new GoogleContactService(Common.GoogleAuthentication, Common.TestGoogleContactGroupName);
			IAvegaClientRepository avegaClientRepository = new IntranetAvegaClientRepository(new AvegaAuthentication("notfound", "wrongpassword"));
			AvegaContactService avegaContactService = new AvegaContactService(googleContactService, avegaClientRepository);

			Assert.IsFalse(avegaContactService.IsAuthenticationValid);

		}
		public void shouldCreateContactOnGoogleContactOnNewContact() {
			GoogleContactService googleContactService = new GoogleContactService(Common.GoogleAuthentication, Common.TestGoogleContactGroupName);
			IAvegaClientRepository avegaClientRepository = new IntranetAvegaClientRepository(Common.AvegaAuthentication);

			AvegaContactService avegaContactService = new AvegaContactService(googleContactService, avegaClientRepository);
			
			var syncResult = avegaContactService.SynchronizeWithGoogleContact(new AvegaContact("Mikael Test"+DateTime.Now.Ticks));

			Assert.IsTrue(syncResult.ContactWasCreated);
		}
		public void shouldRaiseWarningOnGoogleContactWarning() {
			GoogleContactService googleContactService = new GoogleContactService(Common.GoogleAuthentication, Common.TestGoogleContactGroupName);

			GoogleContactService_Accessor googleContactService_acc = new GoogleContactService_Accessor(new PrivateObject(googleContactService));
			IAvegaClientRepository avegaClientRepository = new IntranetAvegaClientRepository(Common.AvegaAuthentication);

			AvegaContactService avegaContactService = new AvegaContactService(googleContactService, avegaClientRepository);

			bool isRaised = false;
			avegaContactService.Warning += (sender, ev) => {
				Assert.IsTrue(ev.Message.Contains("Warning message"));
				Console.WriteLine(ev.Message);
				isRaised = true;
			};

			googleContactService_acc.OnWarning(new WarningEventArgs("Warning message"));
			Assert.IsTrue(isRaised);
		}
		public void shouldUpdateContactWhenContactExistInGoogleContact() {
			GoogleContactService googleContactService = new GoogleContactService(Common.GoogleAuthentication, Common.TestGoogleContactGroupName);
			IAvegaClientRepository avegaClientRepository = new IntranetAvegaClientRepository(Common.AvegaAuthentication);

			AvegaContactService avegaContactService = new AvegaContactService(googleContactService, avegaClientRepository);

			var contact = new AvegaContact("Mikael Test"+DateTime.Now.Ticks);
			var syncResultA = avegaContactService.SynchronizeWithGoogleContact(contact);
			googleContactService.InvalidateCache();

			contact.MobilePhone = "12345678";
			var syncResultB = avegaContactService.SynchronizeWithGoogleContact(contact);
			googleContactService.InvalidateCache();

			var syncResultC = avegaContactService.SynchronizeWithGoogleContact(contact);
			googleContactService.InvalidateCache();


			Assert.IsTrue(syncResultB.ContactWasUpdated);
			Assert.IsTrue(syncResultC.ContactWasUpdated);
		}
		public void ImportForMikael(string googleUsername, string googlePassword, string avegaUsername, string avegaPassword) {


			GoogleContactService googleContactService = new GoogleContactService(
				new GoogleAuthentication(googleUsername, googlePassword), "Avega"
			);
			IAvegaClientRepository avegaClientRepository = new IntranetAvegaClientRepository(
				new AvegaAuthentication(avegaUsername, avegaPassword)
			);
			IAvegaContactService contactService = new AvegaContactService(googleContactService, avegaClientRepository);

			bool authenticationErrors = false;
			if (!googleContactService.IsAuthenticationValid) {
				SetWarningText("Failed to authenticate google login");
				authenticationErrors = true;
			}

			if (!avegaClientRepository.IsAuthenticationValid) {
				SetWarningText("Failed to authenticate AvegaGroup intranet login");
				authenticationErrors = true;
			}

			if (authenticationErrors) return;

			contactService.ContactDataFetched += (sender, ev) => {
				SetResultText(string.Format("Fetching contact {0} of {1} - {2}"
					,ev.CurrentContactIndex
					,ev.TotalContactToFetch
					,ev.DataFetched
				));
			};

			contactService.Warning += (sender, ev) => {
				SetWarningText(ev.Message);
			};

			var contacts = contactService.GetAllContacts();
			int count = 0;

			foreach (var contact in contacts) {
				if (abortImport) return;

				contactService.SynchronizeWithGoogleContact(contact);
				OnContactUpdated(new ContactSynchronizedEventArgs(count + 1, contacts.Count, contact));

				count++;
			}

		}