public void GetSecurityGroupFromReferenceTest() { using (var httpTest = new HttpTest()) { Identifier serverId = Guid.NewGuid(); Identifier securityGroupId = Guid.NewGuid(); const string securityGroupName = "{group-name}"; httpTest.RespondWithJson(new Server { SecurityGroups = { new SecurityGroupReference { Name = securityGroupName } } }); httpTest.RespondWithJson(new SecurityGroupCollection { new SecurityGroup { Id = Guid.NewGuid(), Name = "default" }, new SecurityGroup { Id = securityGroupId, Name = securityGroupName } }); httpTest.RespondWithJson(new SecurityGroup { Id = securityGroupId }); var server = _compute.GetServer(serverId); var securityGroupRef = server.SecurityGroups.First(); SecurityGroup result = securityGroupRef.GetSecurityGroup(); Assert.NotNull(result); Assert.Equal(securityGroupId, result.Id); } }
public void CreateServerMetadata() { using (var httpTest = new HttpTest()) { const string key = "stuff"; Identifier serverId = "1"; httpTest.RespondWithJson(new Server { Id = serverId }); var server = _compute.GetServer(serverId); server.Metadata.Create(key, "things"); Assert.True(server.Metadata.ContainsKey(key)); httpTest.ShouldHaveCalled($"*/servers/{serverId}/metadata/{key}"); } }