public void findAndOpen() { var pool = PoolResources.CombinedResourcePool; MyAssert.Equals("common from b", pool.FindAndOpen("COMMON/CONTENT.txt")); MyAssert.Equals("from b", pool.FindAndOpen("content.txt")); Assert.IsNull(pool.FindAndOpen("common/c.txt")); Assert.IsNull(pool.FindAndOpen("hello.txt")); }
public void content([ValueSource(nameof(testPools))] IResourcePool pool) { Stream?getFileContent(IResource dir, string file) => dir.Files .SingleOrDefault(f => f.Path.Parts.Last() == file) ?.OpenContent(); var a = pool.Root.Directories.Single(); var b = a.Directories.Single(d => d.Path.Parts.Last() == "b"); var c = a.Directories.Single(d => d.Path.Parts.Last() == "c"); MyAssert.Equals("42", getFileContent(pool.Root, "answer.txt")); MyAssert.Equals("Hello World!", getFileContent(pool.Root, "hello.txt")); MyAssert.Equals("1337", getFileContent(b, "content.txt")); MyAssert.Equals("Zanzarah", getFileContent(c, "content.txt")); }
public void content() { Stream?getFileContent(IResource dir, string file) => dir.Files .SingleOrDefault(f => f.Name == file) ?.OpenContent(); var a = pool.Root.Directories.First(d => d.Name == "a"); var b = pool.Root.Directories.First(d => d.Name == "b"); var common = pool.Root.Directories.First(d => d.Name == "common"); MyAssert.Equals("from b", getFileContent(pool.Root, "content.txt")); MyAssert.Equals("also from a", getFileContent(a, "hello.txt")); MyAssert.Equals("also from b", getFileContent(b, "hello.txt")); MyAssert.Equals("common from b", getFileContent(common, "content.txt")); MyAssert.Equals("common extra from a", getFileContent(common, "a.txt")); MyAssert.Equals("common extra from b", getFileContent(common, "b.txt")); }
public void AllRoutines() { var project = new Project(ItemName, ItemMkScrsh, ItemChkKB, ItemChkMouse, ItemChkApps, ItemChkBrowsers, ItemActive); MyAssert.Equals(project.Name, ItemName); MyAssert.Equals(project.MakeScreenshots, ItemMkScrsh); Assert.AreEqual(project.CheckKeyboard, ItemChkKB); MyAssert.Equals(project.CheckMouse, ItemChkMouse); MyAssert.Equals(project.CheckApps, ItemChkApps); MyAssert.Equals(project.CheckBrowsers, ItemChkBrowsers); Assert.AreEqual(project.Active, ItemActive); // test saving project.Save(); // user2 must be retrieved from the DB now var project2 = ProjectModel.Find(project.Id); MyAssert.Equals(project2.Name, ItemName); MyAssert.Equals(project2.MakeScreenshots, ItemMkScrsh); Assert.AreEqual(project2.CheckKeyboard, ItemChkKB); MyAssert.Equals(project2.CheckMouse, ItemChkMouse); MyAssert.Equals(project2.CheckApps, ItemChkApps); MyAssert.Equals(project2.CheckBrowsers, ItemChkBrowsers); Assert.AreEqual(project2.Active, ItemActive); project2.Delete(); try { ProjectModel.Find(project.Id); } catch (Exception e) { return; } throw new Exception("Project is still found"); }
public void AllRoutines() { var user = new User(ItemLogin, ItemFullName, ItemPassword, ItemIsAdmin, ItemAddress, ItemGST, ItemIRD, ItemEnabled); MyAssert.Equals(user.Login, ItemLogin); MyAssert.Equals(user.FullName, ItemFullName); Assert.AreEqual(user.IsAdmin, ItemIsAdmin); MyAssert.Equals(user.Address, ItemAddress); MyAssert.Equals(user.GSTNumber, ItemGST); MyAssert.Equals(user.IRDNumber, ItemIRD); Assert.AreEqual(user.Enabled, ItemEnabled); // test saving user.Save(); // user2 must be retrieved from the DB now var user2 = UserModel.Find(user.Id); MyAssert.Equals(user2.Login, ItemLogin); MyAssert.Equals(user2.FullName, ItemFullName); Assert.AreEqual(user2.IsAdmin, ItemIsAdmin); MyAssert.Equals(user2.Address, ItemAddress); MyAssert.Equals(user2.GSTNumber, ItemGST); MyAssert.Equals(user2.IRDNumber, ItemIRD); Assert.AreEqual(user2.Enabled, ItemEnabled); user2.Delete(); try { UserModel.Find(user.Id); }catch (Exception e) { return; } throw new Exception("User is still found"); }