コード例 #1
0
            public void WillAddHashedOriginalUrlsAsKey()
            {
                var testable = new TestableReductionRepository();
                var md5      = Hasher.Hash("urlssss");

                testable.ClassUnderTest.AddReduction(md5, "urls");

                Assert.Equal("urls", testable.ClassUnderTest.Dictionary[md5]);
            }
コード例 #2
0
            public void WillRetrieveNullIfNotExists()
            {
                var testable = new TestableReductionRepository();
                var md5      = Hasher.Hash("urlssss");

                testable.ClassUnderTest.Dictionary.Add(md5, "newUrl");

                var result = testable.ClassUnderTest.FindReduction("urls");

                Assert.Null(result);
            }
コード例 #3
0
            public void WillNotAddDuplicateKeys()
            {
                var testable = new TestableReductionRepository();
                var md5      = Hasher.Hash("urlssss");

                testable.ClassUnderTest.Dictionary.Add(md5, "urls");

                testable.ClassUnderTest.AddReduction(md5, "urls");

                Assert.Equal(1, testable.ClassUnderTest.Dictionary.Keys.Cast <Guid>().Where(x => x == md5).Count());
            }
コード例 #4
0
            public void WillGetPreviouslySavedEntriesFromStore()
            {
                RRContainer.Current = null;
                var testable  = new TestableReductionRepository();
                var key       = Hasher.Hash("url1");
                var mockStore = new Mock <IStore>();

                mockStore.Setup(x => x.GetSavedUrls()).Returns(new Dictionary <Guid, string>()
                {
                    { key, "url1" }
                });
                RRContainer.Current = new Container(x => { x.For <IStore>().Use(mockStore.Object); });

                var result = testable.ClassUnderTest;

                Thread.Sleep(200);

                Assert.True(result.Dictionary[key] as string == "url1");
                Assert.True(testable.ClassUnderTest.HasLoadedSavedEntries);
                RRContainer.Current = null;
            }