public void GetWithInvalidArgsExpectedReturnsNewService() { var services = new Dev2.Runtime.ServiceModel.Services(); var result = services.Get("xxxxx", Guid.Empty, Guid.Empty); Assert.AreEqual(Guid.Empty, result.ResourceID); }
public void Services_Get_WithPluginServiceWebRequestPoco_ShouldReturnPluginService() { //------------Setup for test-------------------------- var services = new Dev2.Runtime.ServiceModel.Services(); var webRequestPoco = new WebRequestPoco { ResourceType = "PluginService" }; //------------Execute Test--------------------------- var service = services.Get(JsonConvert.SerializeObject(webRequestPoco), Guid.Empty, Guid.Empty); //------------Assert Results------------------------- Assert.IsNotNull(service); Assert.IsInstanceOfType(service, typeof(PluginService)); }
static void Verify_IsReadOnly(bool isAuthorized) { //------------Setup for test-------------------------- var resourceID = Guid.NewGuid(); var authorizationService = new Mock<IAuthorizationService>(); authorizationService.Setup(a => a.IsAuthorized(AuthorizationContext.Contribute, resourceID.ToString())).Returns(isAuthorized).Verifiable(); var services = new Dev2.Runtime.ServiceModel.Services(new Mock<IResourceCatalog>().Object, authorizationService.Object); //------------Execute Test--------------------------- var result = services.IsReadOnly(resourceID.ToString(), Guid.NewGuid(), Guid.NewGuid()); //------------Assert Results------------------------- Assert.AreNotEqual(isAuthorized, result.IsReadOnly); authorizationService.Verify(a => a.IsAuthorized(AuthorizationContext.Contribute, resourceID.ToString())); }