static void CleanupFolder(string folder) { if (_solutionFolder == null) { InitalizePaths(); } int tryCount = 0; for ( ;;) { try { while (Directory.Exists(folder)) { Directory.Delete(folder, true); } Directory.CreateDirectory(folder); File.WriteAllText(Path.Combine(folder, "TestWrite.txt"), "Test write works."); File.Delete(Path.Combine(folder, "TestWrite.txt")); return; } catch (Exception ex) { if (++tryCount == 20) { throw; } ConsoleMonitor.Info("While cleaning up test directory. Retrying.", ex); Thread.Sleep(100); } } }
public static void CleanupFolder(string folder) { int tryCount = 0; for ( ; ;) { try { if (Directory.Exists(folder)) { Directory.Delete(folder, true); } Directory.CreateDirectory(folder); File.WriteAllText(Path.Combine(folder, "TestWrite.txt"), "Test write works."); File.Delete(Path.Combine(folder, "TestWrite.txt")); return; } catch (Exception ex) { if (++tryCount == 20) { throw; } ConsoleMonitor.Info().Send(ex, "While cleaning up test directory. Retrying."); System.Threading.Thread.Sleep(100); } } }
public static void DeleteFolder(string directoryPath, bool recreate = false) { int tryCount = 0; for ( ; ;) { try { if (Directory.Exists(directoryPath)) { Directory.Delete(directoryPath, true); } if (recreate) { Directory.CreateDirectory(directoryPath); File.WriteAllText(Path.Combine(directoryPath, "TestWrite.txt"), "Test write works."); File.Delete(Path.Combine(directoryPath, "TestWrite.txt")); } return; } catch (Exception ex) { if (++tryCount == 20) { throw; } ConsoleMonitor.Info().Send(ex, "While cleaning up directory '{0}'. Retrying.", directoryPath); System.Threading.Thread.Sleep(100); } } }
public static void Main() { Console.WriteLine("ConsoleMonitor instance...."); ConsoleMonitor monitor = new ConsoleMonitor(); monitor.Write(); monitor.Dispose(); }
public static void Main(string[] args) { if (args.Length != 1) { Console.WriteLine("You need add the path of your HAP-NodeJS directory to continue like an argument."); Console.WriteLine("Ex: mono HapSharp.Host.Console.exe /Users/user/HapSharp/HAP-NodeJS"); return; } var hapNodeJsPath = args[0]; if (!Directory.Exists(hapNodeJsPath)) { throw new DirectoryNotFoundException(hapNodeJsPath); } //This class provides the handling of the output log messages var monitor = new ConsoleMonitor(); //Our HAP session manages our runner, this step only adds our prefered monitor var session = new HapSession(monitor); //Now we need add Accessories and MessagesDelegates //Our first element must be a bridgeCore, it contains all other accesories in session session.Add <BridgedCoreMessageDelegate> (new BridgedCore("Console Net Bridge", "22:32:43:54:45:14")); //Now, we add all the accessories from the Shared Project //LightMessageDelegate handles the logic of a simple light with two states on/off session.Add <CustomLightMessageDelegate>(new LightAccessory("Humidity Example", "A1:32:45:66:57:73")); //There are different ways of add new accessories, it depends in your needs how to do it var motionSensorAccessory = new MotionSensorAccessory("Motion Sensor Example", "A1:42:35:67:55:73"); var motionSensorMessageDelegate = new CustomMotionSensorMessageDelegate(motionSensorAccessory); session.Add(new AccessoryHost(motionSensorAccessory, motionSensorMessageDelegate)); var regulableLightAccessory = new RegulableLightAccessory("Regulable Light Example", "A1:A2:35:A7:15:73"); session.Add(regulableLightAccessory, new CustomRegulableLightMessageDelegate(regulableLightAccessory)); session.Add <CustomTemperatureMessageDelegate>(new TemperatureAccessory("Temperature Example", "11:32:75:36:17:73")); //Also you can create custom libraries or nugets to share with the community! session.Add <NugetHumidityMessageDelegate>(new CustomHumidityAccessory("Example of Humidity", "A2:12:41:67:55:73")); //Now with all accessories added to our host we can start the session //ยก Before run next step you will need a Broker running in background ! //Remember follow the Requisites steps in Github readme!! //https://github.com/netonjm/HapSharp session.Start(hapNodeJsPath); Console.ReadKey(); }
private static async void ConsoleUpdater() { Server.RUNTIME = DateTime.Now; while (true) { //ConsoleMonitor.Check(); ConsoleMonitor.Update(INTERACTIVE_CONSOLE); await Task.Delay(1000); } }
static public void InitalizePaths() { if (_solutionFolder.IsEmptyPath) { NormalizedPath path = AppContext.BaseDirectory; var s = path.PathsToFirstPart(null, new[] { "CK-Monitoring.sln" }).FirstOrDefault(p => File.Exists(p)); if (s.IsEmptyPath) { throw new InvalidOperationException($"Unable to find CK-Monitoring.sln above '{AppContext.BaseDirectory}'."); } _solutionFolder = s.RemoveLastPart(); LogFile.RootLogPath = Path.Combine(_solutionFolder, "Tests", "CK.Monitoring.Tests", "Logs"); ConsoleMonitor.Info($"SolutionFolder is: {_solutionFolder}\r\nRootLogPath is: {LogFile.RootLogPath}"); } }
static void Main(string[] args) { var airspace = new Airspace(new FlightValidator(), 80000, 80000, 500, 20000); var decoder = new FlightDecoder(airspace, TransponderReceiverFactory.CreateTransponderDataReceiver()); var log = new FileLog(); var separation = new FlightSeparation(log, airspace); var monitor = new ConsoleMonitor(new ConsoleLog(), airspace, separation); while (true) { Thread.Sleep(100); } }
public void Setup() { _eventHandled = false; _console = Substitute.For <ILog>(); _airspace = Substitute.For <IAirspace>(); _separation = Substitute.For <ISeparation>(); _uut = new ConsoleMonitor(_console, _airspace, _separation); _airspace.FlightAddedEvent += (sender, args) => _flightAddedEventArg = args; _airspace.FlightAddedEvent += (sender, args) => _eventHandled = true; _separation.SeparationWarningEvent += (sender, args) => _separationWarningEventArg = args; _separation.SeparationWarningEvent += (sender, args) => _eventHandled = true; }
//Service webService; public Startup() { logger.Info("####################### starting service before RunService() call"); //RunService(); Microsoft.SystemForCrossDomainIdentityManagement.IMonitor monitor = new ConsoleMonitor(); var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; //var filepath = baseDirectory + "\\TargetFile.csv"; var filepath = "TargetFile.csv"; Microsoft.SystemForCrossDomainIdentityManagement.IProvider provider = new FileProvider(filepath); this.starter = new Microsoft.SystemForCrossDomainIdentityManagement.WebApplicationStarter( provider, monitor); }
static void Main(string[] args) { //Console.WriteLine("Thread.CurrentThread.ManagedThreadId:{0}", Thread.CurrentThread.ManagedThreadId); //MyClass myClass = new MyClass(10); //myClass.Run(); //GC.Collect(); ////GC.SuppressFinalize(myClass); //GC.Collect(); var guid = Guid.NewGuid().ToString("N"); Console.WriteLine("ConsoleMonitor instance....{0}", guid); ConsoleMonitor monitor = new ConsoleMonitor(); monitor.Write(); monitor.Dispose(); }
private static void InitalizePaths() { string p = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; // => Yodii.Engine.Tests/bin/Debug/ p = Path.GetDirectoryName(p); // => Yodii.Engine.Tests/bin/ p = Path.GetDirectoryName(p); // => Yodii.Engine.Tests/ p = Path.GetDirectoryName(p); // ==> Yodii.Engine.Tests/TestData _testData = Path.Combine(p, "TestData"); do { p = Path.GetDirectoryName(p); }while(!File.Exists(Path.Combine(p, "Yodii.sln"))); _solutionFolder = p; ConsoleMonitor.Info().Send("SolutionFolder is: {1}\r\nTestData is: {0}", _testData, _solutionFolder); CleanupTestFolder(); }
public override FileProviderBase CreateProvider() { FileProviderBase result = null; try { string fileName = CommaDelimitedFileUnitTest.ComposeFileName(); IMonitor monitor = new ConsoleMonitor(); result = new AccessConnectivityEngineFileProviderFactory(fileName, monitor).CreateProvider(); return(result); } catch { if (result != null) { result.Dispose(); result = null; } throw; } }
public static void InitalizePaths() { if (_solutionFolder != null) { return; } #if NET451 string p = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath; #else string p = Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationBasePath; #endif do { p = Path.GetDirectoryName(p); }while(!File.Exists(Path.Combine(p, "CK-Core.sln"))); _solutionFolder = p; _testFolder = Path.Combine(_solutionFolder, "Tests", "CK.Monitoring.Tests", "TestFolder"); AppSettings.Default.Initialize(_ => null); SystemActivityMonitor.RootLogPath = Path.Combine(_testFolder, "RootLogPath"); ConsoleMonitor.Info().Send("SolutionFolder is: {1}\r\nTestFolder is: {0}\r\nRootLogPath is: {2}", _testFolder, _solutionFolder, SystemActivityMonitor.RootLogPath); CleanupTestFolder(); }
public static void Main(string[] args) { //This class provides the handling of the output log messages var monitor = new ConsoleMonitor(); //Our HAP session manages our runner, this step only adds our prefered monitor var session = new CodeSession(monitor); var message = new ExtensionActivated(); session.MessageDelegates.Add(message); var command = new SayHelloCommand("extension.sayHello"); session.MessageDelegates.Add(command); var xamlCompletionItemProvider = new XamlCompletionItemProvider("completion"); session.MessageDelegates.Add(xamlCompletionItemProvider); session.Start(); Console.ReadKey(); }
public void SetConsoleMonitor(ConsoleMonitor monitor) { mConsoleMonitor = monitor; }
public void SetConsoleMonitor (ConsoleMonitor monitor) { mConsoleMonitor = monitor; }
public void TestRetrieveGroup() { Uri resourceBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); string fileName = CommaDelimitedFileUnitTest.ComposeFileName(); FileProviderBase provider = null; try { provider = new AccessConnectivityEngineFileProviderFactory(fileName, monitor).CreateProvider(); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(resourceBase); Guid groupIdentifier = Guid.NewGuid(); string resourceRelativeValue = string.Format( CultureInfo.InvariantCulture, WebServiceUnitTest.AddressRelativeGroupTemplate, groupIdentifier); Uri resourceRelative = new Uri(resourceRelativeValue, UriKind.Relative); Uri resource = new Uri(resourceBase, resourceRelative); HttpWebResponse response = null; WebClient client = null; try { client = new WebClient(); try { client.DownloadData(resource); } catch (WebException exception) { response = exception.Response as HttpWebResponse; } } finally { if (client != null) { client.Dispose(); client = null; } } Assert.IsNotNull(response); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); } finally { if (webService != null) { webService.Dispose(); webService = null; } } } finally { if (provider != null) { provider.Dispose(); provider = null; } } }
public void TestCreateUser() { Uri resourceBase = new Uri(WebServiceUnitTest.AddressBase); Uri resourceUsers = new Uri(WebServiceUnitTest.AddressRelativeUsers, UriKind.Relative); IMonitor monitor = new ConsoleMonitor(); string fileName = CommaDelimitedFileUnitTest.ComposeFileName(); FileProviderBase provider = null; try { provider = new AccessConnectivityEngineFileProviderFactory(fileName, monitor).CreateProvider(); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(resourceBase); IDictionary <string, object> json = SampleComposer.Instance.ComposeUserResource().ToJson(); string characters = WebServiceUnitTest.Serializer.Value.Serialize(json); byte[] bytes = Encoding.UTF8.GetBytes(characters); Uri resource = new Uri(resourceBase, resourceUsers); WebClient client = null; try { client = new WebClient(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); byte[] response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); string responseCharacters = Encoding.UTF8.GetString(response); IReadOnlyDictionary <string, object> responseJson = WebServiceUnitTest.Serializer.Value.Deserialize <Dictionary <string, object> >(responseCharacters); Core2EnterpriseUser user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(user); Assert.IsNotNull( user .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2EnterpriseUser, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier)); Assert.IsNotNull(user.Metadata); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType)); string resourcePathValue = string.Concat(WebServiceUnitTest.AddressRelativeUser, user.Identifier); Uri resourcePath = new Uri(resourcePathValue, UriKind.Relative); resource = new Uri(resourceBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } finally { if (client != null) { client.Dispose(); client = null; } } } finally { if (webService != null) { webService.Dispose(); webService = null; } } } finally { if (provider != null) { provider.Dispose(); provider = null; } } }
public void TestRetrieveGroup() { Uri addressBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); string fileName = CommaDelimitedFileUnitTest.ComposeFileName(); FileProviderBase provider = null; try { provider = new FileProvider(fileName); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(addressBase); Guid groupIdentifier = Guid.NewGuid(); string resourceRelative = string.Format( CultureInfo.InvariantCulture, WebServiceUnitTest.AddressRelativeGroupTemplate, groupIdentifier); Uri resource = new Uri(addressBase, resourceRelative); HttpWebResponse response = null; WebClient client = null; try { client = new WebClient(); try { client.DownloadData(resource); } catch (WebException exception) { response = exception.Response as HttpWebResponse; } } finally { if (client != null) { client.Dispose(); client = null; } } Assert.IsNotNull(response); Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode); } finally { if (webService != null) { webService.Dispose(); webService = null; } } } finally { if (provider != null) { provider.Dispose(); provider = null; } } }
public void TestCreateUser() { Uri addressBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); string fileName = CommaDelimitedFileUnitTest.ComposeFileName(); FileProviderBase provider = null; try { provider = new FileProvider(fileName); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(addressBase); IDictionary<string, object> json = ProviderTestTemplate<FileProvider>.ComposeUserResource().ToJson(); string characters = WebServiceUnitTest.Serializer.Value.Serialize(json); byte[] bytes = Encoding.UTF8.GetBytes(characters); Uri resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); WebClient client = null; try { client = new WebClient(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); byte[] response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); string responseCharacters = Encoding.UTF8.GetString(response); IReadOnlyDictionary<string, object> responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); Core2EnterpriseUser user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(user); Assert.IsNotNull( user .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2EnterpriseUser, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier)); Assert.IsNotNull(user.Metadata); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType)); string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, user.Identifier); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } finally { if (client != null) { client.Dispose(); client = null; } } } finally { if (webService != null) { webService.Dispose(); webService = null; } } } finally { if (provider != null) { provider.Dispose(); provider = null; } } }
private static void Main(string[] arguments) { if (null == arguments) { Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments); return; } if (Program.NumberArguments > arguments.Length) { Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments); return; } string argumentBaseAddress = arguments[0]; Uri baseAddress = null; if (!Uri.TryCreate(argumentBaseAddress, UriKind.Absolute, out baseAddress)) { Console.WriteLine(FileProvisioningAgentResources.InformationCommandLineArguments); return; } string informationBaseAddress = string.Format( CultureInfo.InvariantCulture, ProvisioningAgentResources.InformationBaseAddressTemplate, argumentBaseAddress); Console.WriteLine(informationBaseAddress); IMonitor monitor = new ConsoleMonitor(); FileProviderBase provider = null; try { provider = new FileProvider(arguments[1]); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(baseAddress); string informationStarted = string.Format( CultureInfo.InvariantCulture, ProvisioningAgentResources.InformationAgentStartedTemplate, argumentBaseAddress); Console.WriteLine(informationStarted); Console.WriteLine(ProvisioningAgentResources.PromptTerminate); Console.ReadKey(true); } finally { if (webService != null) { webService.Dispose(); webService = null; } } } finally { if (provider != null) { provider.Dispose(); provider = null; } } }
public void TestLifecycleUser() { Uri addressBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); IAmazonWebServicesIdentityAnchoringBehavior anchoringBehavior = new AnchoringByIdentifierBehavior(); AmazonWebServicesProviderBase provider = new AmazonWebServicesProvider(WebServiceUnitTest.CredentialsProfileName, anchoringBehavior); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(addressBase); string identifier = Guid.NewGuid().ToString(); string identifierExternal = Guid.NewGuid().ToString(); Core2EnterpriseUser user = new Core2EnterpriseUser() { Identifier = identifier, ExternalIdentifier = identifierExternal }; IDictionary<string, object> json = user.ToJson(); string characters = WebServiceUnitTest.Serializer.Value.Serialize(json); byte[] bytes = Encoding.UTF8.GetBytes(characters); Uri resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); WebClient client = null; try { client = new WebClient(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); byte[] response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); string responseCharacters = Encoding.UTF8.GetString(response); IReadOnlyDictionary<string, object> responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(user); Assert.IsNotNull( user .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2EnterpriseUser, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier)); string identifierAmazon = user.Identifier; string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierAmazon); resource = new Uri(addressBase, resourcePath); try { Assert.IsNotNull(user.Metadata); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Metadata.ResourceType)); Assert.IsFalse(string.Equals(identifier, identifierAmazon, StringComparison.OrdinalIgnoreCase)); response = client.DownloadData(resource); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(user); Assert.IsNotNull( user .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2EnterpriseUser, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(user.Identifier)); Assert.IsTrue(string.Equals(user.Identifier, identifierAmazon, StringComparison.OrdinalIgnoreCase)); Assert.IsFalse(string.IsNullOrWhiteSpace(user.ExternalIdentifier)); Assert.IsTrue(string.Equals(user.ExternalIdentifier, identifierExternal, StringComparison.OrdinalIgnoreCase)); } finally { bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { if (client != null) { client.Dispose(); client = null; } } } finally { if (webService != null) { webService.Dispose(); webService = null; } } }
public void TestLifecycleGroup() { Uri addressBase = new Uri(WebServiceUnitTest.AddressBase); IMonitor monitor = new ConsoleMonitor(); IAmazonWebServicesIdentityAnchoringBehavior anchoringBehavior = new AnchoringByIdentifierBehavior(); AmazonWebServicesProviderBase provider = new AmazonWebServicesProvider(WebServiceUnitTest.CredentialsProfileName, anchoringBehavior); Service webService = null; try { webService = new WebService(monitor, provider); webService.Start(addressBase); string identifierGroup; string identifierGroupExternal; string identifierMemberOne; string identifierMemberTwo; Uri resource; WebClient client = null; try { IDictionary<string, object> json; string characters; byte[] bytes; byte[] response; string responseCharacters; IReadOnlyDictionary<string, object> responseJson; Core2EnterpriseUser user; Member member; IReadOnlyCollection<Member> members; client = new WebClient(); identifierMemberOne = Guid.NewGuid().ToString(); string identifierMemberOneExternal = Guid.NewGuid().ToString(); user = new Core2EnterpriseUser() { Identifier = identifierMemberOne, ExternalIdentifier = identifierMemberOneExternal }; json = user.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); identifierMemberOne = user.Identifier; try { member = new Member() { Value = identifierMemberOne }; members = new Member[] { member }; identifierGroup = Guid.NewGuid().ToString(); identifierGroupExternal = Guid.NewGuid().ToString(); WindowsAzureActiveDirectoryGroup group = new WindowsAzureActiveDirectoryGroup() { Identifier = identifierGroup, ExternalIdentifier = identifierGroupExternal, Members = members }; json = group.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeGroups); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(group); Assert.IsNotNull( group .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.WindowsAzureActiveDirectoryGroup, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier)); string identifierGroupAmazon = group.Identifier; try { Assert.IsNotNull(group.Metadata); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Metadata.ResourceType)); Assert.IsFalse(string.Equals(identifierGroup, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase)); string resourcePath = string.Format( CultureInfo.InvariantCulture, WebServiceUnitTest.AddressRelativeGroupTemplate, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); response = client.DownloadData(resource); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); group = new WindowsAzureActiveDirectoryGroupJsonDeserializingFactory().Create(responseJson); Assert.IsNotNull(group); Assert.IsNotNull( group .Schemas .SingleOrDefault( (string item) => string.Equals( SchemaIdentifiers.Core2Group, item, StringComparison.Ordinal))); Assert.IsFalse(string.IsNullOrWhiteSpace(group.Identifier)); Assert.IsTrue(string.Equals(group.Identifier, identifierGroupAmazon, StringComparison.OrdinalIgnoreCase)); Assert.IsFalse(string.IsNullOrWhiteSpace(group.ExternalIdentifier)); Assert.IsTrue(string.Equals(group.ExternalIdentifier, identifierGroupExternal, StringComparison.OrdinalIgnoreCase)); identifierMemberTwo = Guid.NewGuid().ToString(); string identifierMemberTwoExternal = Guid.NewGuid().ToString(); user = new Core2EnterpriseUser() { Identifier = identifierMemberTwo, ExternalIdentifier = identifierMemberTwoExternal }; json = user.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resource = new Uri(addressBase, WebServiceUnitTest.AddressRelativeUsers); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebRequestMethods.Http.Post, bytes); responseCharacters = Encoding.UTF8.GetString(response); responseJson = WebServiceUnitTest.Serializer.Value.Deserialize<Dictionary<string, object>>(responseCharacters); user = new Core2EnterpriseUserJsonDeserializingFactory().Create(responseJson); identifierMemberTwo = user.Identifier; try { IResourceIdentifier resourceIdentifier = new ResourceIdentifier() { Identifier = identifierGroupAmazon, SchemaIdentifier = SchemaIdentifiers.WindowsAzureActiveDirectoryGroup }; IPath path = Microsoft.SystemForCrossDomainIdentityManagement.Path.Create(AttributeNames.Members); OperationValue operationValue; PatchOperation operation; IReadOnlyCollection<PatchOperation> operations; PatchRequest2 patch; operationValue = new OperationValue() { Value = identifierMemberTwo }; operation = new PatchOperation() { Name = OperationName.Add, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); operationValue = new OperationValue() { Value = identifierMemberTwo }; operation = new PatchOperation() { Name = OperationName.Remove, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); operationValue = new OperationValue() { Value = identifierMemberOne }; operation = new PatchOperation() { Name = OperationName.Remove, Path = path }; operations = new PatchOperation[] { operation }; operation.AddValue(operationValue); patch = new PatchRequest2(); patch.AddOperation(operation); json = patch.ToJson(); characters = WebServiceUnitTest.Serializer.Value.Serialize(json); bytes = Encoding.UTF8.GetBytes(characters); resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); client.Headers.Clear(); client.Headers.Add(HttpRequestHeader.ContentType, WebServiceUnitTest.ContentTypeJson); response = client.UploadData(resource.AbsoluteUri, WebServiceUnitTest.MethodPatch, bytes); } finally { resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberTwo); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeGroup, identifierGroupAmazon); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { string resourcePath = string.Concat(WebServiceUnitTest.AddressRelativeUser, identifierMemberOne); resource = new Uri(addressBase, resourcePath); bytes = new byte[0]; client.UploadData(resource, WebServiceUnitTest.MethodDelete, bytes); } } finally { if (client != null) { client.Dispose(); client = null; } } } finally { if (webService != null) { webService.Dispose(); webService = null; } } }