Example #1
0
        private void VerifyQueryResponse(ResourceType type, PayloadObject fromInsert, PayloadObject fromQuery)
        {
            bool keyShouldMatch = true;

            if (type.Key.Properties.Any(p => p.Facets.FixedLength))
            {
                foreach (NodeProperty property in type.Key.Properties.Where(p => p.Facets.FixedLength))
                {
                    // this may not always be correct for all types, but it seems to work most of the time;
                    int length;
                    if (property.Facets.MaxSize.HasValue)
                    {
                        length = property.Facets.MaxSize.Value;
                    }
                    else if (property.Type == Clr.Types.Decimal)
                    {
                        length = property.Facets.Precision.Value + property.Facets.Scale.Value;
                    }
                    else
                    {
                        continue;
                    }

                    string value = null;
                    if (fromInsert.PayloadProperties.Any(p => p.Name == property.Name))
                    {
                        value = (fromInsert[property.Name] as PayloadSimpleProperty).Value;
                    }
                    else
                    {
                        value = fromInsert.CustomEpmMappedProperties[property.Name];
                    }

                    if (value != null && value.Length < length)
                    {
                        keyShouldMatch = false;
                    }
                }
            }

            if (keyShouldMatch)
            {
                AstoriaTestLog.AreEqual(fromInsert.AbsoluteUri, fromQuery.AbsoluteUri, "fromInsert.AbsoluteUri != fromQuery.AbsoluteUri", false);
            }
            else
            {
                AstoriaTestLog.IsFalse(fromInsert.AbsoluteUri == fromQuery.AbsoluteUri, "fromInsert.AbsoluteUri == fromQuery.AbsoluteUri, despite fixed-length string");
            }

            // leave it to the concurrency tests to check the more involved etags
            if (!type.Properties.Any(p => p.Facets.ConcurrencyModeFixed && p.Facets.FixedLength))
            {
                AstoriaTestLog.AreEqual(fromInsert.ETag, fromQuery.ETag, "fromInsert.ETag != fromQuery.ETag", false);
            }

            VerifyProperties(type, fromInsert, fromQuery, false, rp => true);
        }
Example #2
0
        protected void RetrieveAPICallLog()
        {
            string directoryPath  = Path.Combine(Workspace.DataService.DestinationFolder, APICallLog.DirectoryName);
            string markerFilePath = Path.Combine(directoryPath, APICallLog.MarkerFileName);

            if (!this.LogAPICalls)
            {
                AstoriaTestLog.IsFalse(TrustedMethods.IsFileExists(markerFilePath), "Marker file should have been cleaned up by prior request");
                return;
            }

            IOUtil.EnsureFileDeleted(markerFilePath);

            this.APICallLogXml     = new XElement("APICallLog");
            this.APICallLogEntries = new List <APICallLogEntry>();

            string[] files;
            // re-query each time, in case any new files were created
            while ((files = Directory.GetFiles(directoryPath, "*.xml")).Length > 0)
            {
                foreach (string filePath in files.OrderBy(f => f)) //NEED TO BE IN CORRECT ORDER
                {
                    string   text    = File.ReadAllText(filePath);
                    XElement element = null;
                    try
                    {
                        element = XElement.Parse(text);
                    }
                    catch
                    { }

                    if (element != null)
                    {
                        this.APICallLogXml.Add(element);
                        this.APICallLogEntries.Add(APICallLogEntry.FromXml(element));
                    }
                    else
                    {
                        this.APICallLogXml.Add(text);
                        this.APICallLogEntries.Add(new APICallLogEntry(text, new KeyValuePair <string, string> [0])); //this will hopefully ALWAYS fail to compare
                    }

                    IOUtil.EnsureFileDeleted(filePath);
                }
            }

            //if (APICallLogEntries.Any(e => e.MethodName == APICallLog.UnterminatedCall))
            //{
            //    foreach (APICallLogEntry entry in APICallLogEntries)
            //        AstoriaTestLog.WriteLine("(Observed) - " + entry.ToString());
            //    AstoriaTestLog.FailAndContinue(new Microsoft.Test.ModuleCore.TestFailedException("Un-terminated API calls detected"));
            //}
        }
Example #3
0
        protected void SetupAPICallLog()
        {
            string directoryPath  = Path.Combine(Workspace.DataService.DestinationFolder, APICallLog.DirectoryName);
            string markerFilePath = Path.Combine(directoryPath, APICallLog.MarkerFileName);

            if (!this.LogAPICalls)
            {
                AstoriaTestLog.IsFalse(TrustedMethods.IsFileExists(markerFilePath), "Marker file should have been cleaned up by prior request");
                AstoriaTestLog.IsFalse(TrustedMethods.IsDirectoryNotEmpty(directoryPath), "Directory should be empty!");
                return;
            }

            IOUtil.EnsureDirectoryExists(directoryPath);
            IOUtil.CreateEmptyFile(markerFilePath);
        }
Example #4
0
 public static void IsFalse(bool condition)
 {
     AstoriaTestLog.IsFalse(condition, "");
 }