Пример #1
0
        public void SetApiTest_ValueFormatException()
        {
            var testFile = TestFiles.Jpg;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        Type           = "Boolean",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Printed",
                                    Category = "Time"
                                }
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual(ex.Message, "Request parameters missing or have incorrect format");
        }
Пример #2
0
        static async Task Set(SetOptions options)
        {
            var query = GetQuery(options);

            if (!string.IsNullOrEmpty(options.Project))
            {
                await query.SetCurrentTimerProject(await GetMatchingProject(query, options.Project));
            }
            if (!string.IsNullOrEmpty(options.Description))
            {
                await query.SetCurrentTimerDescription(options.Description);
            }
            if (options.Tags.Count > 0)
            {
                if (options.Tags.Count == 1 && options.Tags[0] == "~")
                {
                    await query.SetCurrentTimerTags(new string[0]);
                }
                else
                {
                    await query.SetCurrentTimerTags(options.Tags);
                }
            }
            await Current(options);
        }
Пример #3
0
        public void SetApiTest_PropertyName()
        {
            var testFile = TestFiles.Docx;
            var now      = DateTime.Now.ToString("MM-dd-yyyy hh:mm:ss");

            var options = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = now,
                        Type           = "DateTime",
                        SearchCriteria = new SearchCriteria
                        {
                            NameOptions = new NameOptions
                            {
                                Value = "Date"
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.SetCount, 0);
        }
Пример #4
0
 public void SetData(object documentData, CompletionHandler handler, params FieldPath[] mergeFields)
 {
     _documentReference.Set(documentData.ToNativeFieldValues(), SetOptions.MergeFieldPaths(new JavaList <Firebase.Firestore.FieldPath>(mergeFields.Select(x => x.ToNative())))).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
     {
         handler?.Invoke(task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception));
     }));
 }
        /// <summary>
        /// The add or update collection data async.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <typeparam name="TEntity">
        /// Entity maybe a Model Class
        /// </typeparam>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown if Argument Null Exception
        /// </exception>
        public async Task AddOrUpdateCollectionDataAsync <TEntity>(
            [NotNull] TEntity entity,
            [NotNull] SetOptions options,
            [NotNull] params string[] name)
            where TEntity : class
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var documentReference = fireStoreDb?.Document(GetDocumentPath(name));

            if (documentReference != null)
            {
                if (options == null)
                {
                    await documentReference.SetAsync(entity, SetOptions.MergeAll).ConfigureAwait(false);
                }
                else
                {
                    await documentReference.SetAsync(entity, options).ConfigureAwait(false);
                }
            }
        }
Пример #6
0
        public void SetApiTest_PropertyValue()
        {
            var testFile = TestFiles.Docx;

            var options = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "Microsoft Office Word Application",
                        Type           = "String",
                        SearchCriteria = new SearchCriteria
                        {
                            ValueOptions = new ValueOptions
                            {
                                Value = "Microsoft Office Word",
                                Type  = "String"
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.SetCount, 0);
        }
Пример #7
0
        public void SetApiTest_DocumentProtectedException()
        {
            var testFile = TestFiles.PasswordProtected;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Creator",
                                    Category = "Person"
                                }
                            }
                        },
                        Type = "String"
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual($"The specified file '{testFile.FullName}' is protected.", ex.Message);
        }
Пример #8
0
        public void SetApiTest_DateTime()
        {
            var testFile = TestFiles.Xlsx;
            var now      = DateTime.Now;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = now.ToString("MM-dd-yyyy hh:mm:ss"),
                        Type           = "DateTime",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Created",
                                    Category = "Time"
                                }
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.Greater(result.SetCount, 0);
        }
Пример #9
0
        public void SetApiTest_NoChanges()
        {
            var testFile = TestFiles.Psd;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        Type           = "String",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Owner",
                                    Category = "Legal"
                                }
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual($"There are no changes in metadata.", ex.Message);
        }
Пример #10
0
        public void SetApiTest_Integer()
        {
            var testFile = TestFiles.Docx;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "14",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "SoftwareVersion",
                                    Category = "Tool"
                                }
                            }
                        },
                        Type = "integer"
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.Greater(result.SetCount, 0);
        }
Пример #11
0
        public void SetApiTest_UnsupportedFormat()
        {
            var testFile = TestFiles.Json;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Creator",
                                    Category = "Person"
                                }
                            }
                        },
                        Type = "String"
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual($"The specified file '{testFile.FullName}' has type which is not currently supported.", ex.Message);
        }
Пример #12
0
        public void SetApiTest_FileNotFound()
        {
            var testFile = TestFiles.NotExist;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        Type           = "Boolean",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Creator",
                                    Category = "Person"
                                }
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual($"Can't find file located at '{testFile.FullName}'.", ex.Message);
        }
Пример #13
0
        public void MergeFields_FieldPaths_Empty()
        {
            var options = SetOptions.MergeFields(new FieldPath[0]);

            Assert.Empty(options.FieldMask);
            Assert.True(options.Merge);
        }
Пример #14
0
        internal bool Show()
        {
            OpenFileDialog Dialog = new OpenFileDialog
            {
                AddExtension     = false,
                CheckFileExists  = false,
                DereferenceLinks = true,
                Filter           = "Folders|\n",
                InitialDirectory = CurrentDirectory,
                Multiselect      = false,
                Title            = LocString(LocCode.SelectFolder)
            };
            object VistaDialog = typeof(OpenFileDialog).GetMethod("CreateVistaDialog", Flags).Invoke(Dialog, new object[0]);

            typeof(OpenFileDialog).GetMethod("OnBeforeVistaDialog", Flags).Invoke(Dialog, new[] { VistaDialog });
            SetOptions.Invoke(VistaDialog, new object[] { (uint)GetOptions.Invoke(Dialog, new object[0]) | PickFolders });
            object[] AdviseParameters = new[] { VistaDialogEventsConstructor.Invoke(new[] { Dialog }), 0U };
            IFileDialog.GetMethod("Advise").Invoke(VistaDialog, AdviseParameters);
            try
            {
                bool Result = (int)IFileDialog.GetMethod("Show").Invoke(VistaDialog, new object[] { Zero }) == 0;
                if (Result)
                {
                    Path = Dialog.FileName;
                }
                return(Result);
            }
            finally { IFileDialog.GetMethod("Unadvise").Invoke(VistaDialog, new[] { AdviseParameters[1] }); }
        }
Пример #15
0
        public void SetApiTest_WrongTypeForTag()
        {
            var testFile = TestFiles.Pptx;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "true",
                        Type           = "Boolean",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Creator",
                                    Category = "Person"
                                }
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { MetadataApi.Set(request); });

            Assert.AreEqual($"There are no changes in metadata.", ex.Message);
        }
Пример #16
0
        public void SetApiTest()
        {
            var testFile = TestFiles.Docx;
            var options  = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "NewAuthor",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                ExactTag = new Tag
                                {
                                    Name     = "Creator",
                                    Category = "Person"
                                }
                            }
                        },
                        Type = "String"
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.Greater(result.SetCount, 0);
        }
Пример #17
0
 public void SetData <T>(T documentData, IEnumerable <string> mergeFields, CompletionHandler handler) where T : class
 {
     DocumentReference.Set(documentData.ToNativeFieldValues(), SetOptions.MergeFields(mergeFields.ToArray())).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
     {
         handler?.Invoke(task.IsSuccessful ? null : new CloudFirestoreException(task.Exception.Message));
     }));
 }
Пример #18
0
        public void SetApiTest_PossibleTagName()
        {
            var testFile = TestFiles.Xlsx;

            var options = new SetOptions
            {
                FileInfo   = testFile.ToFileInfo(),
                Properties = new List <SetProperty>
                {
                    new SetProperty
                    {
                        NewValue       = "New Creator",
                        Type           = "String",
                        SearchCriteria = new SearchCriteria
                        {
                            TagOptions = new TagOptions
                            {
                                PossibleName = "creator"
                            }
                        },
                    }
                }
            };

            var request = new SetRequest(options);

            var result = MetadataApi.Set(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.SetCount, 0);
        }
Пример #19
0
        public void MergeFields_Strings_Valid()
        {
            var options = SetOptions.MergeFields("a.b", "c");

            Assert.Equal(new[] { new FieldPath("a", "b"), new FieldPath("c") }, options.FieldMask);
            Assert.True(options.Merge);
        }
Пример #20
0
        public void MergeFields_Strings_Empty()
        {
            var options = SetOptions.MergeFields(new string[0]);

            Assert.Empty(options.FieldMask);
            Assert.True(options.Merge);
        }
Пример #21
0
 public void SetData(object documentData, CompletionHandler handler, params string[] mergeFields)
 {
     _documentReference.Set(documentData.ToNativeFieldValues(), SetOptions.MergeFields(mergeFields)).AddOnCompleteListener(new OnCompleteHandlerListener((task) =>
     {
         handler?.Invoke(task.IsSuccessful ? null : ExceptionMapper.Map(task.Exception));
     }));
 }
Пример #22
0
        public void SetsAdditionalArgs()
        {
            var processor = new SetOptions(null, null, null, "additional args");
            var args      = new StartMongoDbArgs();

            processor.Process(args);
            args.AdditionalArgs.Should().Be("additional args");
        }
Пример #23
0
        public void SetsDbPath()
        {
            var processor = new SetOptions(null, "db path", null, null);
            var args      = new StartMongoDbArgs();

            processor.Process(args);
            args.DbFolderPath.Should().Be("db path");
        }
Пример #24
0
        public void SetsPort()
        {
            var processor = new SetOptions(null, null, "12345", null);
            var args      = new StartMongoDbArgs();

            processor.Process(args);
            args.Port.Value.Should().Be(12345);
        }
Пример #25
0
        private static int HandleSet(SetOptions options)
        {
            VersionFile versionFile = new VersionFile();

            versionFile.SetVersion(options.Version);
            versionFile.SerializeToFile();
            return(0);
        }
Пример #26
0
        public void SetsExePath()
        {
            var processor = new SetOptions("exe path", null, null, null);
            var args      = new StartMongoDbArgs();

            processor.Process(args);
            args.ExePath.Should().Be("exe path");
        }
Пример #27
0
        public void SetMaxAndDefaultValueForWorkerInput(NumericUpDown workersInput, Dictionary <RunOptionsEnums, string> runOptionsDictionary)
        {
            if (runOptionsDictionary.Count != 0)
            {
                SetOptions options = new SetOptions( );

                options.SetWorkerOptions(workersInput, runOptionsDictionary);
            }
        }
Пример #28
0
        public void MergeFields_FieldPaths_Valid()
        {
            var path1   = new FieldPath("a", "b");
            var path2   = new FieldPath("c");
            var options = SetOptions.MergeFields(path1, path2);

            Assert.Equal(new[] { path1, path2 }, options.FieldMask);
            Assert.True(options.Merge);
        }
Пример #29
0
        public void SetMsbuildNunitPaths(TextBox MsBuildPathTextBox, TextBox NunitPathTextBox, Dictionary <RunOptionsEnums, string> runOptionsDictionary)
        {
            if (runOptionsDictionary.Count != 0)
            {
                SetOptions options = new SetOptions( );

                options.SetBuilderRunnerPath(MsBuildPathTextBox, NunitPathTextBox, runOptionsDictionary);
            }
        }
Пример #30
0
        public void SetXmlOptions(TextBox nameTextBox, RadioButton nunitTwoStyleRadioButton, RadioButton nunitThreeStyleRadioButton, Dictionary <RunOptionsEnums, string> runOptionsDictionary)
        {
            if (runOptionsDictionary.Count != 0)
            {
                SetOptions options = new SetOptions( );

                options.SetXmlReportNameAndStyle(nameTextBox, nunitTwoStyleRadioButton, nunitThreeStyleRadioButton, runOptionsDictionary);
            }
        }
Пример #31
0
 private void ShowOptionsWindow(object sender, EventArgs e)
 {
     var optWindow = new SetOptions(LogWindow, WvwMatch, MainWindow1);
     optWindow.Show();
 }
Пример #32
0
        private byte[] OnSetOptions(GameSession session, byte[] body)
        {
            SetOptions request = new SetOptions();
            using(Stream stream = new MemoryStream(body)) {
                request.Deserialize(stream);
            }

            return null;
        }