public void ShimGetDateTimeFakeTest() { using (ShimsContext.Create()) { System.Fakes.ShimDateTime.NowGet = () => new DateTime(2000, 1, 1); var foo = LibraryShop.GetDateTime(); var expected = new DateTime(2000, 1, 1); Assert.AreEqual(expected, foo, "Data nieprawidłowa"); } }
public void ShimReadFileFakeTest() { using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()) { const string path = "cośtam123"; const string expected = "cośtamwpliku"; System.IO.Fakes.ShimFileStream.ConstructorStringFileMode = (@this, p, f) => { var shim = new System.IO.Fakes.ShimFileStream(@this); }; System.IO.Fakes.ShimStreamReader.ConstructorStream = (@this, s) => { var shim = new System.IO.Fakes.ShimStreamReader(@this) { ReadToEnd = () => expected }; }; var actual = LibraryShop.Read(path); Assert.AreEqual(expected, actual); } }
public static void Main() { LibraryShop ba = new LibraryShop(); Client client = new Client("Zbigniew", "Kolonko", "82070111111", 67, Gender.Male); ba.AddClient(client); Borrow borrow = new Borrow(client, DateTime.Parse("2019-02-12 12:33"), "Władca Pierścieni - 2 miesiące", 5M); Borrow borrow1 = new Borrow(client, DateTime.Parse("2019-01-11 12:37"), "Gra o Tron", 5M); ba.AddBorrow(client, borrow); ba.AddBorrow(client, borrow1); System.Diagnostics.Debug.WriteLine("WYPISYWANIE TESTÓW:"); System.Console.WriteLine("Godzina: " + LibraryShop.GetDateTime()); System.Console.WriteLine(); System.Console.WriteLine(ba.FindClient("Zbigniew").FirstName + " " + ba.FindClient("Zbigniew").LastName); System.Console.WriteLine("Wypożyczonych książek " + ba.FindBorrows("Zbigniew").Count); System.Console.WriteLine("Pieniądze do zapłaty za wypożyczenie klienta (20 groszy za dzień): " + ba.BorrowPayment(borrow) + "zł " + ba.BorrowPayment(borrow1) + "zł"); System.Console.WriteLine(); System.Console.WriteLine(ba.DisplayStatistics()); ba.DeleteClient(client); System.Console.WriteLine(ba.DisplayStatistics()); System.Console.ReadLine(); //.Diagnostics.Debug.WriteLine(ba.BorrowPayment(borrow)+" "+"zł"); }