private void ValidateResetCommand(bool allFieldsVisible) { var viewModel = new DetailedItemViewModel(_story); viewModel.InitializeAsync().Wait(); Assert.IsTrue(viewModel.OnlyDefaultFieldsAreShown, "Only default fields should be visible when detailed item is initialized"); foreach (var field in viewModel.FilteredEntityFields) { field.IsSelected = allFieldsVisible; viewModel.ToggleEntityFieldVisibilityCommand.Execute(null); } Assert.IsFalse(viewModel.OnlyDefaultFieldsAreShown, "Visible fields should be different than default fields"); viewModel.ResetFieldsCustomizationCommand.Execute(null); var dynamicFieldsCache = ExposedClass.From(typeof(FieldsCache)); var cache = dynamicFieldsCache._defaultFieldsCache as FieldsCache.Metadata; var persistedVisibleFields = cache.data[Utility.GetConcreteEntityType(_story)]; Assert.AreEqual(persistedVisibleFields.Count, viewModel.VisibleFields.Count(), "Inconsistent number of visible fields"); foreach (var field in viewModel.VisibleFields) { Assert.IsTrue(persistedVisibleFields.Contains(field.Name), $"Field {field.Name} should be visible"); } Assert.IsTrue(viewModel.OnlyDefaultFieldsAreShown, "Only default fields should be visible after reset command"); }
public void TestCleanup() { ExposedClass.From(typeof(FieldsCache))._persistedFieldsCache = _persistedFieldsCache; ExposedClass.From(typeof(FieldsCache)).PersistFieldsMetadata(); TestCleanupInternal(); }
public void FieldsCacheTests_GetVisibleFieldsForEntity_DefaultEntityType_DefaultFields() { Dictionary <string, HashSet <string> > _defaultFieldsDictionary; _defaultFieldsDictionary = ExposedClass.From(typeof(FieldsCache))._defaultFieldsCache.data; ValidateFieldsInCache(Task.TYPE_TASK, _defaultFieldsDictionary[Task.TYPE_TASK].ToList()); }
public static dynamic Expose(this object obj) { var asType = obj as Type; if (asType != null) { return(ExposedClass.From(asType)); } return(ExposedObject.From(obj)); }
public void TestInitialize() { var instance = FieldsCache.Instance; var dynamicFieldsCache = ExposedClass.From(typeof(FieldsCache)); var cache = dynamicFieldsCache._persistedFieldsCache as FieldsCache.Metadata; _persistedFieldsCache = Utilities.Utility.Clone(cache); dynamicFieldsCache._persistedFieldsCache = new FieldsCache.Metadata { data = new Dictionary <string, HashSet <string> >(), version = 1 }; TestInitializeInternal(); }
public void FieldsCacheTests_ResetVisibleFieldsForEntity_ExistingEntityType() { var entity = new WorkItem(); FieldsCache.Instance.UpdateVisibleFieldsForEntity(Requirement.SUBTYPE_DOCUMENT, new List <FieldViewModel> { new FieldViewModel(entity, "name", "label", true) }); FieldsCache.Instance.ResetVisibleFieldsForEntity(Requirement.SUBTYPE_DOCUMENT); Dictionary <string, HashSet <string> > _defaultFieldsDictionary; _defaultFieldsDictionary = ExposedClass.From(typeof(FieldsCache))._defaultFieldsCache.data; ValidateFieldsInCache(Requirement.SUBTYPE_DOCUMENT, _defaultFieldsDictionary[Requirement.SUBTYPE_DOCUMENT].ToList()); }
public void WorkspaceSessionPersistanceManagerTests_UpdateHistory_ResetApplication_Success() { OctaneConfiguration.Url = Guid.NewGuid().ToString(); CollectionAssert.AreEqual(new List <string>(), WorkspaceSessionPersistanceManager.History, "Invalid initial history"); WorkspaceSessionPersistanceManager.UpdateHistory("1"); var exposedHistoryManager = ExposedClass.From(typeof(WorkspaceSessionPersistanceManager)); exposedHistoryManager._metadata = null; CollectionAssert.AreEqual(new List <string> { "1" }, WorkspaceSessionPersistanceManager.History, "Mismatched history after reset"); WorkspaceSessionPersistanceManager.UpdateHistory("2"); CollectionAssert.AreEqual(new List <string> { "2", "1" }, WorkspaceSessionPersistanceManager.History, "Mismatched history"); }
static void Main(string[] args) { var foo = ExposedObject.From(new Foo()); string stuff = foo.Bar.Baz._stuff; Console.WriteLine(stuff); foo.Name = "Bilbo"; Console.WriteLine(foo.Name); Console.WriteLine(foo.DoubleIt()); Console.WriteLine(foo.Reverse("Bilbo")); Console.WriteLine(foo._field2); foo._field2 = "Hello, Bilbo!"; Console.WriteLine(foo._field2); var realList = new List <int>(); var exposedList = ExposedObject.From(realList); // Read a private field - prints 0 Console.WriteLine(exposedList._size); // Modify a private field exposedList._items = new int[] { 5, 4, 3, 2, 1 }; // Modify another private field exposedList._size = 5; // Call a private method exposedList.EnsureCapacity(20); // Add a value to the list exposedList.Add(0); // Enumerate the list. Prints "5 4 3 2 1 0" foreach (var x in exposedList) { Console.WriteLine(x); } ThisIsAnUnrelatedInterface newInstance = ExposedObject.New <ThisIsAnUnrelatedInterface>(typeof(ImVisible), "MyName"); Console.WriteLine(newInstance.Name); // Call a static method var staticJumble = ExposedClass.From(typeof(StaticJumble)); string reversed = staticJumble.Reversed("Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm. Pinnace holystone mizzenmast quarter crow's nest nipperkin grog yardarm hempen halter furl. Swab barque interloper chantey doubloon starboard grog black jack gangway rutters."); Console.WriteLine(reversed); var internalJumble = ExposedClass.From("Super.Secret.Library.InternalJumble", typeof(ImVisible).Assembly); reversed = internalJumble.Reversed(reversed); Console.WriteLine(reversed); var internalPrivateJumble = ExposedClass.From("Super.Secret.Library.InternalPrivateJumble", typeof(ImVisible).Assembly); reversed = internalPrivateJumble.MeToo.Reversed(reversed); Console.WriteLine(reversed); // Call a generic method var enumerableType = ExposedClass.From(typeof(System.Linq.Enumerable)); Console.WriteLine( enumerableType.Max(new[] { 1, 3, 5, 3, 1 })); }