public void Initialize() { shimContext = ShimsContext.Create(); SetupShims(); spListItemManager = new SPListItemManager(DummyString, DummyGuid, DummyGuid); privateObject = new PrivateObject(spListItemManager); }
/// <summary> /// This method is fake and these parameters are required, even though not all of them are used /// </summary> private void GetFieldSpecialValuesThrowsException( SPListItemManager listItemManager, SPField spField, string stringValue, object value, out string fieldEditValue, out string fieldTextValue, out string fieldHtmlValue) { throw new Exception("Dummy Exception"); }
/// <summary> /// This method is fake and these parameters are required, even though not all of them are used /// </summary> private void GetFieldSpecialValues( SPListItemManager listItemManager, SPField spField, string stringValue, object value, out string fieldEditValue, out string fieldTextValue, out string fieldHtmlValue) { fieldEditValue = DummyString; fieldTextValue = DummyString; fieldHtmlValue = DummyString; }
public void Constructor_SPListNull_ThrowsException() { // Arrange ShimSPSite.ConstructorGuid = (_, guid) => { }; ShimSPSite.AllInstances.OpenWebGuid = (_, guid) => new ShimSPWeb(); ShimSPWeb.AllInstances.ListsGet = _ => new ShimSPListCollection(); ShimSPListCollection.AllInstances.TryGetListString = (_, listName) => null; // Act var instance = new SPListItemManager(DummyString, DummyGuid, DummyGuid); // Assert // Expect an exception }
public void Constructor_OnSuccess_CreatesInstance() { // Arrange ShimSPSite.ConstructorGuid = (_, guid) => { }; ShimSPSite.AllInstances.OpenWebGuid = (_, guid) => new ShimSPWeb(); ShimSPWeb.AllInstances.ListsGet = _ => new ShimSPListCollection(); ShimSPListCollection.AllInstances.TryGetListString = (_, listName) => new ShimSPList(); // Act var instance = new SPListItemManager(DummyString, DummyGuid, DummyGuid); privateObject = new PrivateObject(instance); var rootElementName = privateObject.GetFieldOrProperty("RootElementName") as string; var elementName = privateObject.GetFieldOrProperty("ElementName") as string; // Assert Assert.IsNotNull(instance); Assert.IsNotNull(instance.ParentList); Assert.IsFalse(string.IsNullOrWhiteSpace(rootElementName)); Assert.IsFalse(string.IsNullOrWhiteSpace(elementName)); }