public void ShouldVerifyProfileCanBeFoundSingleResult()
            {
                var profileSniffer = new ProfileSniffer("Joel Spolsky");
                var profile = profileSniffer.GetProfile();

                Assert.AreEqual("AC49KE006R2ZU", profile.CustomerId);
                Assert.AreEqual("1RVDGPM8SWXG4", profile.ListId);
            }
            public void ShouldVerifyProfileCanBeFoundMultipleResults()
            {
                var profileSniffer = new ProfileSniffer("Adam Kahtava");
                var profile = profileSniffer.GetProfile();

                Assert.AreEqual("A2JM0EQJELFL69", profile.CustomerId);
                //Assert.AreEqual("3JU6ASKNUS7B8", profile.ListId);
            }
            public void ShouldReturnErrorsWhenPageSourceNotFound()
            {
                var profileSniffer = new ProfileSniffer();
                profileSniffer.GetProfile();
                
                foreach (var error in profileSniffer.Errors)
                {
                    Debug.WriteLine(error);
                }

                Assert.AreEqual(2, profileSniffer.Errors.Count);
            }
            public void ShouldReturnErrorsWhenUserNotFound()
            {
                var profileSniffer = new ProfileSniffer("gonzo the great and cookie monster");
                var profile = profileSniffer.GetProfile();

                Debug.WriteLine(profile.CustomerId);
                Debug.WriteLine(profile.ListId);

                foreach (var error in profileSniffer.Errors)
                {
                    Debug.WriteLine(error);
                }

                Assert.AreEqual(2, profileSniffer.Errors.Count);
            }
Beispiel #5
0
        private static Profile DiscoverUser(string username)
        {
            username = username.Scrub();
            Assert.ValidInput(username, "username");

            if (ServiceCache.IsInCache <Profile>(username))
            {
                var cachedProfile = (Profile)ServiceCache.GetFromCache <Profile>(username);
                if (cachedProfile != null)
                {
                    return(cachedProfile);
                }
            }

            var sniffer = new ProfileSniffer(username);

            var profile = sniffer.GetProfile();

            HandleErrors(sniffer.Errors);

            return(profile.AddToCache(username));
        }
        private static Profile DiscoverUser(string username)
        {
            username = username.Scrub();
            Assert.ValidInput(username, "username");           

            if (ServiceCache.IsInCache<Profile>(username))
            {
                var cachedProfile = (Profile) ServiceCache.GetFromCache<Profile>(username);
                if (cachedProfile != null)
                {
                    return cachedProfile;
                }
            }

            var sniffer = new ProfileSniffer(username);

            var profile = sniffer.GetProfile();
            
            HandleErrors(sniffer.Errors);

            return profile.AddToCache(username);
        }