public void Test_CompareFiles_PreviousMustHaveListValues() { var file = new ServiceTagFile() { Values = new List <ServiceTagResult>() { new ServiceTagResult { Name = "Test" } } }; Assert.Throws <Exception>(() => AzureIpFileFunctions.CompareFiles(file, new ServiceTagFile())); }
public void Test_CompareFiles_NoPrior_ExpectCurrent() { var file = new ServiceTagFile() { Values = new List <ServiceTagResult>() { new ServiceTagResult { Name = "Test" } } }; var delta = AzureIpFileFunctions.CompareFiles(file, null); Assert.Equal(delta.Count == 1 && delta[0].Name == "Test", true); }
public void Test_CompareFiles_DeltaIsLatest() { // old var prior = new ServiceTagFile() { Values = new List <ServiceTagResult>() }; prior.Values.Add(new ServiceTagResult() { Id = "a", Properties = new ServiceTagProperties() { ChangeNumber = "9" } }); prior.Values.Add(new ServiceTagResult() { Id = "b", Properties = new ServiceTagProperties() { ChangeNumber = "9" } }); //newer var current = new ServiceTagFile() { Values = new List <ServiceTagResult>() }; current.Values.Add(new ServiceTagResult() { Id = "a", Properties = new ServiceTagProperties() { ChangeNumber = "9" } }); current.Values.Add(new ServiceTagResult() { Id = "b", Properties = new ServiceTagProperties() { ChangeNumber = "10" } }); current.Values.Add(new ServiceTagResult() { Id = "c", Properties = new ServiceTagProperties() { ChangeNumber = "1" } }); current.Values.Add(new ServiceTagResult() { Id = "d", Properties = new ServiceTagProperties() { ChangeNumber = "2" } }); var delta = AzureIpFileFunctions.CompareFiles(current, prior); // expect only result from current where the id matches and change number is > same id in prior // or the result entry is new Assert.Equal(delta.Count, 3); Assert.NotNull(delta.Single(r => r.Id == "b" && r.Properties.ChangeNumber == "10")); Assert.NotNull(delta.Single(r => r.Id == "c" && r.Properties.ChangeNumber == "1")); Assert.NotNull(delta.Single(r => r.Id == "d" && r.Properties.ChangeNumber == "2")); }
public void Test_CompareFiles_CurrentFileMissing() { Assert.Throws <Exception>(() => AzureIpFileFunctions.CompareFiles(null, null)); }