Beispiel #1
0
        public void TestRemoveSuccess()
        {
            // arrange
            var fixture  = new InMemory();
            var expected = 0;
            var usr      = new UserEntity();

            usr.SetId("*****@*****.**");
            // act
            fixture.Create(usr);
            var actual = fixture.Count();

            Assert.AreEqual(1, actual);
            fixture.Remove("*****@*****.**");
            actual = fixture.Count();
            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void TestConstructorSuccess()
        {
            // arrange act
            var expected = new InMemory();
            var actual   = new InMemory();

            // assert
            Assert.AreEqual(expected.Count(), actual.Count());
        }
Beispiel #3
0
        public void TestConstructorFailure()
        {
            // arrange
            var expected = new InMemory();
            var actual   = new InMemory();

            // act
            actual.Add(new UserEntity());
            actual.Add(new BlabEntity());
            // assert
            Assert.AreNotEqual(expected.Count(), actual.Count());
        }
Beispiel #4
0
        public void TestCountSuccess()
        {
            // arrange
            var expected = 1;
            var fixture  = new InMemory();

            // act
            fixture.Create(new UserEntity());
            var actual = fixture.Count();

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void TestRemoveFailure()
        {
            // arrange
            var fixture = new InMemory();
            var usr     = new UserEntity();

            usr.SetId("*****@*****.**");
            // act assert
            fixture.Create(usr);
            var actual = fixture.Count();

            Assert.AreEqual(1, actual);
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => fixture.Remove("*****@*****.**"));
        }
Beispiel #6
0
        public void TestConstructorOverrideSuccess()
        {
            // arrange
            UserEntity[] users =
            {
                new UserEntity(),
                new UserEntity(),
                new UserEntity(),
                new UserEntity()
            };
            var expected = 4;
            // act
            var fixture = new InMemory(users);
            var actual  = fixture.Count();

            // assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #7
0
        private static void Main(string[] args)
        {
            InMemory myNewCache = new InMemory();

            string strFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, "../../XmlFiles/ListOfUsers.xml");
            var    lstFiles    = new List <string>();

            lstFiles.Add(strFilePath);

            //for (int i = 1; i <= 100; i++)
            //{
            //    string cacheItem1 = "Steve Smith-" + i;
            //    myNewCache.AddToMyCache(i.ToString(CultureInfo.InvariantCulture), cacheItem1, MyCachePriority.NotRemovable, lstFiles);
            //}

            Console.WriteLine(DateTime.Now.ToString(CultureInfo.InvariantCulture));
            for (int i = 1; i <= 250000; i++)
            {
                var car = new Car("Blue" + i, i);
                myNewCache.AddToMyCache(
                    i.ToString(CultureInfo.InvariantCulture), car, MyCachePriority.NotRemovable, lstFiles);
            }

            var myItem10     = myNewCache.GetMyCachedItem("10") as Car;
            var myItem100    = myNewCache.GetMyCachedItem("100") as Car;
            var myItem1000   = myNewCache.GetMyCachedItem("1000") as Car;
            var myItem10000  = myNewCache.GetMyCachedItem("10000") as Car;
            var myItem100000 = myNewCache.GetMyCachedItem("100000") as Car;
            var myItem150000 = myNewCache.GetMyCachedItem("150000") as Car;
            var myItem200000 = myNewCache.GetMyCachedItem("200000") as Car;
            var myItem250000 = myNewCache.GetMyCachedItem("250000") as Car;

            Console.WriteLine(DateTime.Now.ToString(CultureInfo.InvariantCulture) + " (" + myNewCache.Count() + ")");
            while (Console.ReadLine() != "quit")
            {
            }
        }