public void ExportResources_OnValidCall_ConfirmResult() { // Arrange var exported = false; var expectedResult = string.Format(@"<ResourceExporter Success=""{0}"" Message=""{1}"" File=""{2}"" />", true, DummyString, DummyString); ShimResourceExporter.ConstructorSPWeb = (_, __) => { }; ShimResourceExporter.AllInstances.ExportStringOutStringOut = (ResourceExporter exp, out string file, out string message) => { file = DummyString; message = DummyString; exported = true; return(true); }; // Act var result = ResourceGridClass.ExportResources(_web); // Assert this.ShouldSatisfyAllConditions( () => exported.ShouldBeTrue(), () => result.ShouldBe(expectedResult)); }
public void GetResourcePoolDataGrid_OnValidCall_ConfirmResult() { // Arrange var xmlString = $@" <Root WebId='{WebId}' ListId='{ListId}' ItemId='{DummyIntOne}'> <Resource ID='{DummyIntOne}'> <Data Field='ID' HtmlValue='{DummyIntOne}' Type='Number'>{DummyIntOne}</Data> <Data Field='{DummyString}' HtmlValue='{DummyIntOne}' Type='Number'>{DummyIntOne}</Data> </Resource> <IncludeHidden>{true}</IncludeHidden> <IncludeReadOnly>{true}</IncludeReadOnly> <Department ID='{DummyString}'> <Fields Field='Title' /> <Fields Field='RBS'>{DummyString}</Fields> <Fields Field='Managers'>{DummyIntOne};#{DummyString}</Fields> <Fields Field='Executives'>{DummyIntOne};#{DummyString}</Fields> </Department> </Root>"; var count = 0; ShimSPWeb.AllInstances.FeaturesGet = _ => new ShimSPFeatureCollection { ItemGetGuid = guid => { count++; if (count == 1) { return(null); } return(new ShimSPFeature()); } }; ShimResourcePoolManager.AllInstances.GetAllBooleanBoolean = (_, __, ___) => XDocument.Parse(xmlString); ShimDepartmentManager.ConstructorSPWeb = (_, __) => { }; ShimSPListItemManager.AllInstances.GetAll = _ => XDocument.Parse(xmlString); ShimAPITeam.GetTeamStringSPWeb = (_, __) => $@" <Root> <Member ID ='{DummyIntOne}' /> </Root>"; // Act var result = ResourceGridClass.GetResourcePoolDataGrid(xmlString, _web); // Assert this.ShouldSatisfyAllConditions( () => result.ShouldContain(GridTag), () => result.ShouldContain(BodyTag), () => result.ShouldContain(ResourceID), () => result.ShouldContain(ProfilePic), () => result.ShouldContain(ProfilePicUrl), () => result.ShouldContain(IsMyResource)); }
public void GetResourcePoolLayoutGrid_WhenNoRoot_ThrowException() { // Arrange, Act Action action = () => ResourceGridClass.GetResourcePoolLayoutGrid(string.Empty, _web); // Assert var exception = Should.Throw <APIException>(action); this.ShouldSatisfyAllConditions( () => exception.ShouldNotBeNull(), () => exception.Message.ShouldBe(RootElementIsMissing)); }
public void UpdateResourcePoolViews_OnValidCall_ConfirmResult() { // Arrange, Act var result = ResourceGridClass.UpdateResourcePoolViews(DummyString, _web); // Assert this.ShouldSatisfyAllConditions( () => _gridViewUpdated.ShouldBeTrue(), () => _cacheRemoved.ShouldBeTrue(), () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldBe(ResourcePoolViewsClosedTag)); }
public void DeleteResourcePoolResource_WhenRootIsNull_ThrowException() { // Arrange, Act Action action = () => ResourceGridClass.DeleteResourcePoolResource(string.Empty); // Assert var exception = Should.Throw <APIException>(action); this.ShouldSatisfyAllConditions( () => exception.ShouldNotBeNull(), () => exception.Message.ShouldContain(RootElementIsMissing)); }
public void GetResourcePoolViews_OnValidCall_ConfirmResult() { // Arrange, Act var result = ResourceGridClass.GetResourcePoolViews(DummyString, _web); // Assert this.ShouldSatisfyAllConditions( () => _gridViewInitialized.ShouldBeTrue(), () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldContain(ResourcePoolViewsTag), () => result.ShouldContain(ViewsTag), () => result.ShouldContain(RootTags)); }
public void GetResourcePoolDataGridChanges_WhenDeleted_ConfirmResult() { // Arrange var xmlString = CreateXMLForGetResourcePoolDataGridChanges("Deleted", DummyIntOne); // Act var result = ResourceGridClass.GetResourcePoolDataGridChanges(xmlString, _web); // Assert this.ShouldSatisfyAllConditions( () => result.ShouldContain(ResourcePoolDataGridChangesTag), () => result.ShouldNotContain(IAdded)); }
public void DeleteResourcePoolResource_OnValidCall_ConfirmResult() { // Arrange var xmlString = CreateXMLString(); // Act var result = ResourceGridClass.DeleteResourcePoolResource(xmlString); // Assert this.ShouldSatisfyAllConditions( () => _itemDeleted.ShouldBeTrue(), () => result.ShouldContain(DeleteResourcePoolResourceTag)); }
public void ExportResources_OnError_ThrowException() { // Arrange ShimResourceExporter.ConstructorSPWeb = (_, __) => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.ExportResources(_web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void DeleteResourcePoolViews_OnValidCall_ConfirmResult() { // Arrange var xmlString = CreateXMLString(); // Act var result = ResourceGridClass.DeleteResourcePoolViews(xmlString, _web.Instance); // Assert this.ShouldSatisfyAllConditions( () => _gridViewRemoved.ShouldBeTrue(), () => _cacheRemoved.ShouldBeTrue(), () => result.ShouldBe(ResourcePoolViewsClosedTag)); }
public void GetResources_OnError_ThrowException() { // Arrange ShimResourcePoolManager.ConstructorSPWeb = (_, __) => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.GetResources(string.Empty, _web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void RefreshResources_WhenErrorOnAddJob_ThrowException() { // Arrange ShimTimer.AddTimerJobGuidGuidStringInt32StringStringInt32Int32String = (_1, _2, _3, _4, _5, _6, _7, _8, _9) => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.RefreshResources(_web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void UpdateResourcePoolViews_OnError_ThrowException() { // Arrange ShimGridViewManagerFactory.Constructor = _ => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.UpdateResourcePoolViews(DummyString, _web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void GetResourcePoolViews_OnError_ThrowException() { // Arrange ShimCacheStoreCategory.ConstructorSPWeb = (_, __) => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.GetResourcePoolViews(DummyString, _web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void DeleteResourcePoolResource_WhenNoId_ThrowException() { // Arrange var xmlString = "<Root><Resource /></Root>"; // Act Action action = () => ResourceGridClass.DeleteResourcePoolResource(xmlString); // Assert var exception = Should.Throw <APIException>(action); this.ShouldSatisfyAllConditions( () => exception.ShouldNotBeNull(), () => exception.Message.ShouldContain(@"Cannot find the DeleteResourcePoolResource\Resource Id attribute.")); }
public void DeleteResourcePoolResource_WhenInvalidId_ThrowException() { // Arrange var xmlString = $"<Root><Resource Id='{DummyString}'/></Root>"; // Act Action action = () => ResourceGridClass.DeleteResourcePoolResource(xmlString); // Assert var exception = Should.Throw <APIException>(action); this.ShouldSatisfyAllConditions( () => exception.ShouldNotBeNull(), () => exception.Message.ShouldContain(NotValidResourcePoolId)); }
public void GetResourcePoolDataGridChanges_OnError_ThrowException() { // Arrange var xmlString = CreateXMLForGetResourcePoolDataGridChanges(string.Empty, DummyIntOne); ShimGridGanttSettings.ConstructorSPList = (_, __) => { throw new Exception(DummyError); }; // Act Action action = () => ResourceGridClass.GetResourcePoolDataGridChanges(xmlString, _web); // Assert Should.Throw <APIException>(action).Message.ShouldBe(DummyError); }
public void GetResourcePoolLayoutGrid_OnValidCall_ConfirmResult() { // Arrange var xmlString = $@" <Root> <Id>{DummyString}</Id> </Root>"; // Act var result = ResourceGridClass.GetResourcePoolLayoutGrid(xmlString, _web); // Assert this.ShouldSatisfyAllConditions( () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldContain(GridTag), () => result.ShouldContain(CfgTag)); }
public void DeleteResourcePoolResource_WhenResourceDoesNotExist_ThrowException() { // Arrange var xmlString = CreateXMLString(); ShimSPListItemManager.AllInstances.ItemExistsInt32 = (_, __) => false; // Act Action action = () => ResourceGridClass.DeleteResourcePoolResource(xmlString); // Assert var exception = Should.Throw <APIException>(action); this.ShouldSatisfyAllConditions( () => exception.ShouldNotBeNull(), () => exception.Message.ShouldContain(NotValidResourcePoolId)); }
public void TestInitialize() { _itemDeleted = false; _cacheRemoved = false; _gridViewRemoved = false; _gridPersonalViewRemoved = false; _gridGlobalViewRemoved = false; _gridViewInitialized = false; _gridViewAdded = false; _gridViewUpdated = false; _shimObject = ShimsContext.Create(); _testObj = new ResourceGridClass(); _privateObj = new PrivateObject(_testObj); _privateType = new PrivateType(typeof(ResourceGridClass)); SetupShims(); }
public void SaveResourcePoolViews_OnValidCall_EPMLiveResourceGridGlobalView_ConfirmResult() { _GridViewManagerKind = GridViewManagerKind.Global; _gridPersonalViewRemoved = false; _gridGlobalViewRemoved = false; // Arrange, Act var result = ResourceGridClass.SaveResourcePoolViews(DummyString, _web); // Assert this.ShouldSatisfyAllConditions( () => _gridViewAdded.ShouldBeTrue(), () => _gridGlobalViewRemoved.ShouldBeFalse(), () => _gridPersonalViewRemoved.ShouldBeTrue(), () => _cacheRemoved.ShouldBeTrue(), () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldBe(ResourcePoolViewsClosedTag)); }
public void GetResourcePoolDataGridChanges_WhenOtherOption_ConfirmResult() { // Arrange var xmlString = CreateXMLForGetResourcePoolDataGridChanges("Other", DummyIntTwo); ShimUtils.GetGridEnumSPSiteSPFieldStringOutInt32OutStringOut = (SPSite site, SPField field, out string enumValues, out int enumRange, out string enumKeys) => { enumValues = DummyString; enumRange = DummyIntOne; enumKeys = DummyString; }; // Act var result = ResourceGridClass.GetResourcePoolDataGridChanges(xmlString, _web); // Assert this.ShouldSatisfyAllConditions( () => result.ShouldContain(ResourcePoolDataGridChangesTag), () => result.ShouldNotContain(IAdded), () => result.ShouldContain(IOther)); }
public void DeleteResourcePoolResource_WhenPerformDeleteReturnsValue_ConfirmResult() { // Arrange var xmlString = CreateXMLString(); ShimManagementUtilities.PerformDeleteResourceCheckInt32GuidSPWebStringOutStringOut = (int _1, Guid _2, SPWeb _3, out string _4, out string _5) => { _4 = NoValueString; _5 = DummyError; return(false); }; // Act var result = ResourceGridClass.DeleteResourcePoolResource(xmlString); // Assert this.ShouldSatisfyAllConditions( () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldContain(DeleteResourcePoolResourceTag), () => result.ShouldContain(DummyError)); }
public void RefreshResources_OnValidCall_ConfirmResult() { // Arrange var jobAdded = false; var jobEnqueued = false; ShimTimer.AddTimerJobGuidGuidStringInt32StringStringInt32Int32String = (_1, _2, _3, _4, _5, _6, _7, _8, _9) => { jobAdded = true; return(Guid.NewGuid()); }; ShimTimer.EnqueueGuidInt32SPSite = (_, __, ___) => jobEnqueued = true; // Act var result = ResourceGridClass.RefreshResources(_web); // Assert this.ShouldSatisfyAllConditions( () => jobAdded.ShouldBeTrue(), () => jobEnqueued.ShouldBeTrue(), () => result.ShouldNotBeNullOrEmpty(), () => result.ShouldBe(RefreshResourcesSucess)); }