public void EqualsToSameSkus() { ArmSku sku1 = new ArmSku(null, null, null, null, null); ArmSku sku2 = sku1; Assert.IsTrue(sku1.Equals(sku2)); }
public void NotEqualsToOperator(bool expected, string name1, string name2, string family1, string family2) { ArmSku sku1 = new ArmSku(name1, null, null, family1, null); ArmSku sku2 = new ArmSku(name2, null, null, family2, null); Assert.AreEqual(expected, sku1 != sku2); }
public void EqualsToNullSku() { ArmSku sku1 = new ArmSku(null, null, null, null, null); ArmSku sku2 = null; Assert.IsFalse(sku1.Equals(sku2)); }
private ArmSku ReadSku(JObject skuObject) { var sku = new ArmSku(); if (skuObject.TryGetValue("name", out JToken nameValue)) { sku.Name = ReadArmExpression(nameValue); } if (skuObject.TryGetValue("tier", out JToken tierValue)) { sku.Tier = ReadArmExpression(tierValue); } if (skuObject.TryGetValue("size", out JToken sizeValue)) { sku.Size = ReadArmExpression(sizeValue); } if (skuObject.TryGetValue("family", out JToken familyValue)) { sku.Family = ReadArmExpression(familyValue); } if (skuObject.TryGetValue("capacity", out JToken capacityValue)) { sku.Capacity = ReadArmExpression(capacityValue); } return(sku); }
public object VisitSku(ArmSku sku) { Write($"{NewPSArmSkuCommand.KeywordName} "); WriteExpression(sku.Name); if (sku.Capacity != null) { Write(" -Capacity "); WriteExpression(sku.Capacity); } if (sku.Family != null) { Write(" -Family "); WriteExpression(sku.Family); } if (sku.Size != null) { Write(" -Size "); WriteExpression(sku.Size); } if (sku.Tier != null) { Write(" -Tier "); WriteExpression(sku.Tier); } return(null); }
public void EqualsToTier(bool expected, ArmSkuTier tier1, ArmSkuTier tier2) { ArmSku sku1 = new ArmSku(null, tier1, null, null, null); ArmSku sku2 = new ArmSku(null, tier2, null, null, null); Assert.AreEqual(expected, sku1.Equals(sku2), "Skus did not match expected equals"); Assert.AreEqual(expected, sku1.GetHashCode() == sku2.GetHashCode(), $"Hashcodes comparison was expect {expected} but was {!expected}, ({sku1.GetHashCode()}, {sku2.GetHashCode()})"); }
public void EqualsToCapacity(bool expected, int?capacity1, int?capacity2) { ArmSku sku1 = capacity1 == null ? new ArmSku(null, null, null, null, null) : new ArmSku(null, null, null, null, capacity1); ArmSku sku2 = capacity2 == null ? new ArmSku(null, null, null, null, null) : new ArmSku(null, null, null, null, capacity2); Assert.AreEqual(expected, sku1.Equals(sku2), "Skus did not match expected equals"); Assert.AreEqual(expected, sku1.GetHashCode() == sku2.GetHashCode(), $"Hashcodes comparison was expect {expected} but was {!expected}, ({sku1.GetHashCode()}, {sku2.GetHashCode()})"); }
public void InvalidDeserializationTest() { string json = "{\"name\":\"NameForSku\",\"notTier\":\"Basic\",\"size\":\"SizeForSku\",\"family\":\"FamilyForSku\"}"; JsonElement element = JsonDocument.Parse(json).RootElement; ArmSku sku = ArmSku.DeserializeArmSku(element); Assert.IsTrue(sku.Tier == null); Assert.IsTrue(sku.Capacity == null); }
public void DeserializationTest() { string json = "{\"name\":\"NameForSku\",\"tier\":\"Basic\",\"size\":\"SizeForSku\",\"family\":\"FamilyForSku\",\"capacity\":123456789}"; JsonElement element = JsonDocument.Parse(json).RootElement; ArmSku sku = ArmSku.DeserializeArmSku(element); Assert.IsTrue(sku.Name.Equals("NameForSku")); Assert.IsTrue(sku.Capacity == 123456789); }
VisitAction IArmVisitor <VisitAction> .VisitSku(ArmSku sku) { if (ShouldStop(VisitSku(sku), out VisitAction parentAction)) { return(parentAction); } if (VisitDictionaryAndCheckStop(sku, out parentAction)) { return(parentAction); } return(VisitAction.Continue); }
public void EqualsToObject() { ArmSku sku1 = new ArmSku(null, null, null, null, null); object sku2 = new ArmSku("SkuName", null, null, null, null); object stringSku = "random"; Assert.IsFalse(sku1.Equals(stringSku)); object nullSku = null; Assert.IsFalse(sku1.Equals(nullSku)); object sameSku = sku1; Assert.IsTrue(sku1.Equals(sameSku)); Assert.IsFalse(sku1.Equals(sku2)); }
public virtual VisitAction VisitSku(ArmSku sku) => DefaultVisit(sku);
public object VisitSku(ArmSku sku) { throw CreateInvalidException(sku); }
public JToken VisitSku(ArmSku sku) => VisitObject(sku);