public void TestThatConstructorInitializeDocumentWithDescription() { var fixture = new Fixture(); var id = fixture.CreateAnonymous <int>(); var nameSource = fixture.CreateAnonymous <string>(); var nameTarget = fixture.CreateAnonymous <string>(); var reference = fixture.CreateAnonymous <string>(); var description = fixture.CreateAnonymous <string>(); var document = new MyDocument(id, nameSource, nameTarget, reference, description); Assert.That(document, Is.Not.Null); Assert.That(document.Id, Is.EqualTo(id)); Assert.That(document.NameSource, Is.Not.Null); Assert.That(document.NameSource, Is.Not.Empty); Assert.That(document.NameSource, Is.EqualTo(nameSource)); Assert.That(document.NameTarget, Is.Not.Null); Assert.That(document.NameTarget, Is.Not.Empty); Assert.That(document.NameTarget, Is.EqualTo(nameTarget)); Assert.That(document.Reference, Is.Not.Null); Assert.That(document.Reference, Is.Not.Empty); Assert.That(document.Reference, Is.EqualTo(reference)); Assert.That(document.Description, Is.Not.Null); Assert.That(document.Description, Is.Not.Empty); Assert.That(document.Description, Is.EqualTo(description)); }
public void TestThatReferenceSetterRaisesPropertyChangedEvent() { var fixture = new Fixture(); var document = new MyDocument(fixture.CreateAnonymous <int>(), fixture.CreateAnonymous <string>(), fixture.CreateAnonymous <string>(), fixture.CreateAnonymous <string>()); Assert.That(document, Is.Not.Null); var eventCalled = false; document.PropertyChanged += (s, e) => { Assert.That(s, Is.Not.Null); Assert.That(e, Is.Not.Null); Assert.That(e.PropertyName, Is.Not.Null); Assert.That(e.PropertyName, Is.Not.Empty); Assert.That(e.PropertyName, Is.EqualTo("Reference")); eventCalled = true; }; document.Reference = document.Reference; Assert.That(eventCalled, Is.False); document.Reference = fixture.CreateAnonymous <string>(); Assert.That(eventCalled, Is.True); }
private void Redo_Executed(object sender, ExecutedRoutedEventArgs e) { if (MyDocument.CanRedo) { MyDocument.Redo(); } }
public async Task DoOperationsAsync() { BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(this.cosmosContainer, this.cosmosContainer.ClientContext, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes); List <Task <TransactionalBatchOperationResult> > tasks = new List <Task <TransactionalBatchOperationResult> >(); for (int i = 0; i < 100; i++) { tasks.Add(executor.AddAsync(CreateItem(i.ToString()), null, default(CancellationToken))); } await Task.WhenAll(tasks); for (int i = 0; i < 100; i++) { Task <TransactionalBatchOperationResult> task = tasks[i]; TransactionalBatchOperationResult result = await task; Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); MyDocument document = cosmosDefaultJsonSerializer.FromStream <MyDocument>(result.ResourceStream); Assert.AreEqual(i.ToString(), document.id); ItemResponse <MyDocument> storedDoc = await this.cosmosContainer.ReadItemAsync <MyDocument>(i.ToString(), new Cosmos.PartitionKey(i.ToString())); Assert.IsNotNull(storedDoc.Resource); } executor.Dispose(); }
/// <summary> /// default constructor /// </summary> /// <param name="wallGeo"> /// the mapped wall geometry information /// </param> public WallDrawing(WallGeometry wallGeo) { m_coordinateFont = new Font("Verdana", 10, FontStyle.Regular); m_wallLine2D = new WallBaseline2D(); m_myDocument = wallGeo.MyDocument; m_refGeometry = wallGeo; }
public async Task ValidateInvalidRequestOptionsAsync() { BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(this.cosmosContainer, this.cosmosContainer.ClientContext, 20, Constants.MaxDirectModeBatchRequestBodySizeInBytes); string id = Guid.NewGuid().ToString(); MyDocument myDocument = new MyDocument() { id = id, Status = id }; await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => executor.ValidateOperationAsync(new ItemBatchOperation(OperationType.Replace, 0, new Cosmos.PartitionKey(id), id, cosmosDefaultJsonSerializer.ToStream(myDocument)), new ItemRequestOptions() { SessionToken = "something" })); await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => executor.ValidateOperationAsync( new ItemBatchOperation(OperationType.Replace, 0, new Cosmos.PartitionKey(id), id, cosmosDefaultJsonSerializer.ToStream(myDocument)), new ItemRequestOptions() { Properties = new Dictionary <string, object>() { { "test", "test" } } })); await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => executor.ValidateOperationAsync( new ItemBatchOperation(OperationType.Replace, 0, new Cosmos.PartitionKey(id), id, cosmosDefaultJsonSerializer.ToStream(myDocument)), new ItemRequestOptions() { DedicatedGatewayRequestOptions = new DedicatedGatewayRequestOptions { MaxIntegratedCacheStaleness = TimeSpan.FromMinutes(3) } })); }
public async Task DeleteItem_WithBulk() { List <MyDocument> createdDocuments = new List <MyDocument>(); // Create the items List <Task <ItemResponse <MyDocument> > > tasks = new List <Task <ItemResponse <MyDocument> > >(); for (int i = 0; i < 100; i++) { MyDocument createdDocument = CreateItem(i.ToString()); createdDocuments.Add(createdDocument); tasks.Add(ExecuteCreateAsync(this.container, createdDocument)); } await Task.WhenAll(tasks); List <Task <ItemResponse <MyDocument> > > deleteTasks = new List <Task <ItemResponse <MyDocument> > >(); // Delete the items foreach (MyDocument createdDocument in createdDocuments) { deleteTasks.Add(ExecuteDeleteAsync(this.container, createdDocument)); } await Task.WhenAll(deleteTasks); for (int i = 0; i < 100; i++) { Task <ItemResponse <MyDocument> > task = deleteTasks[i]; ItemResponse <MyDocument> result = await task; Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode); } }
public async Task ReplaceItemStream_WithBulk() { List <MyDocument> createdDocuments = new List <MyDocument>(); // Create the items List <Task <ResponseMessage> > tasks = new List <Task <ResponseMessage> >(); for (int i = 0; i < 100; i++) { MyDocument createdDocument = CreateItem(i.ToString()); createdDocuments.Add(createdDocument); tasks.Add(ExecuteCreateStreamAsync(this.container, createdDocument)); } await Task.WhenAll(tasks); List <Task <ResponseMessage> > replaceTasks = new List <Task <ResponseMessage> >(); // Replace the items foreach (MyDocument createdDocument in createdDocuments) { replaceTasks.Add(ExecuteReplaceStreamAsync(this.container, createdDocument)); } await Task.WhenAll(replaceTasks); for (int i = 0; i < 100; i++) { Task <ResponseMessage> task = replaceTasks[i]; ResponseMessage result = await task; Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); } }
public void Save() { using (NSUrl url = NSUrl.FromFilename(GetFileName())) { doc = new MyDocument(url); doc.Save(url, UIDocumentSaveOperation.ForCreating, OperationHandler); } }
public List <MyDocument> PerformRead() { var directory = new DirectoryInfo(path); foreach (var file in directory.GetFiles("*.doc", SearchOption.AllDirectories)) { var doc = new Document(); try { doc.LoadFromFile(file.FullName); var myDoc = new MyDocument { FileName = file.FullName, Content = doc.GetText() }; myDoc.Words = WordBreaker.BreakWords(myDoc.Content); Documents.Add(myDoc); } catch { Application.exceptionsCount++; } } return(Documents); }
/// <summary> /// Method Name : SetAdapterAsync /// Author : Sanket Prajapati /// Creation Date : 9 jan 2018 /// Purpose : Bind Data alert data /// Revision : /// </summary> private async void SetAdapterAsync() { myDocument = new MyDocument(); string errorMessage = string.Empty; try { progressDialog = UIHelper.SetProgressDailoge(Activity); APIResponse <List <DocumentModel> > serviceResponse; serviceResponse = await myDocument.GetDocumentList(UtilityPCL.LoginCustomerData.CustomerId); if (serviceResponse.STATUS) { SetMyDocumentDataBinding(serviceResponse); } else { errorMessage = serviceResponse.Message; } } catch (Exception error) { errorMessage = error.Message; } finally { progressDialog.Dismiss(); if (!string.IsNullOrEmpty(errorMessage)) { AlertMessage(errorMessage); } } }
public async Task DeleteItemStream_WithBulk() { List <MyDocument> createdDocuments = new List <MyDocument>(); // Create the items List <Task <ResponseMessage> > tasks = new List <Task <ResponseMessage> >(); for (int i = 0; i < 100; i++) { MyDocument createdDocument = CreateItem(i.ToString()); createdDocuments.Add(createdDocument); tasks.Add(ExecuteCreateStreamAsync(this.container, createdDocument)); } await Task.WhenAll(tasks); List <Task <ResponseMessage> > deleteTasks = new List <Task <ResponseMessage> >(); // Delete the items foreach (MyDocument createdDocument in createdDocuments) { deleteTasks.Add(ExecuteDeleteStreamAsync(this.container, createdDocument)); } await Task.WhenAll(deleteTasks); for (int i = 0; i < 100; i++) { Task <ResponseMessage> task = deleteTasks[i]; ResponseMessage result = await task; Assert.IsTrue(result.Headers.RequestCharge > 0); Assert.IsFalse(string.IsNullOrEmpty(result.Diagnostics.ToString())); Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode); } }
public Task Handle(MyMessage message, IMessageHandlerContext context) { var document = new MyDocument(); var ravenSession = context.SynchronizedStorageSession.RavenSession(); return(ravenSession.StoreAsync(document)); }
public async Task ReplaceItem_WithBulk() { List <MyDocument> createdDocuments = new List <MyDocument>(); // Create the items List <Task <ItemResponse <MyDocument> > > tasks = new List <Task <ItemResponse <MyDocument> > >(); for (int i = 0; i < 100; i++) { MyDocument createdDocument = CreateItem(i.ToString()); createdDocuments.Add(createdDocument); tasks.Add(ExecuteCreateAsync(this.container, createdDocument)); } await Task.WhenAll(tasks); List <Task <ItemResponse <MyDocument> > > replaceTasks = new List <Task <ItemResponse <MyDocument> > >(); // Replace the items foreach (MyDocument createdDocument in createdDocuments) { replaceTasks.Add(ExecuteReplaceAsync(this.container, createdDocument)); } await Task.WhenAll(replaceTasks); for (int i = 0; i < 100; i++) { Task <ItemResponse <MyDocument> > task = replaceTasks[i]; ItemResponse <MyDocument> result = await task; Assert.IsTrue(result.Headers.RequestCharge > 0); Assert.IsFalse(string.IsNullOrEmpty(result.Diagnostics.ToString())); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); } }
private static CosmosResponseMessage GetResponse(HttpStatusCode statusCode, bool includeItem, int subStatusCode = 0) { CosmosResponseMessage message = new CosmosResponseMessage(statusCode); message.Headers.Continuation = "someContinuation"; if (subStatusCode > 0) { message.Headers.SubStatusCode = (Documents.SubStatusCodes)subStatusCode; } if (includeItem) { MyDocument document = new MyDocument(); document.id = "test"; CosmosFeedResponseUtil <MyDocument> cosmosFeedResponse = new CosmosFeedResponseUtil <MyDocument>(); cosmosFeedResponse.Data = new System.Collections.ObjectModel.Collection <MyDocument>() { document }; message.Content = (new CosmosJsonSerializerCore()).ToStream(cosmosFeedResponse); } return(message); }
private async Task CreateLargeItemStreamWithBulk(int appxItemSize) { List <Task <ResponseMessage> > tasks = new List <Task <ResponseMessage> >(); for (int i = 0; i < 3; i++) { MyDocument item = CreateItem(i.ToString()); if (i == 1) { item.Description = new string('x', appxItemSize); } tasks.Add(ExecuteCreateStreamAsync(this.container, item)); } await Task.WhenAll(tasks); for (int i = 0; i < 3; i++) { Task <ResponseMessage> task = tasks[i]; ResponseMessage result = await task; if (i == 0 || i == 2) { Assert.IsTrue(result.Headers.RequestCharge > 0); Assert.IsFalse(string.IsNullOrEmpty(result.Diagnostics.ToString())); Assert.AreEqual(HttpStatusCode.Created, result.StatusCode); } else { Assert.AreEqual(HttpStatusCode.RequestEntityTooLarge, result.StatusCode); } } }
private static ResponseMessage GetResponse(HttpStatusCode statusCode, bool includeItem, int subStatusCode = 0) { ResponseMessage message = new ResponseMessage(statusCode); message.Headers.ContinuationToken = "someContinuation"; if (subStatusCode > 0) { message.Headers.SubStatusCode = (Documents.SubStatusCodes)subStatusCode; } if (includeItem) { MyDocument document = new MyDocument { id = "test" }; message.Content = new CosmosJsonDotNetSerializer().ToStream(new { Documents = new List <MyDocument>() { document } }); } return(message); }
/// <summary> /// constructor /// </summary> /// <param name="mydoc"> /// the document of the sample /// </param> public SystemInfo(MyDocument mydoc) { m_mydocument = mydoc; m_gridFacesIndices = new List <int>(); m_uncoverFacesIndices = new List <int>(); m_byFaceArray = false; m_index = 0; }
private void questionPlayer_QuestionStopped(object sender, EventArgs e) { // ※これってEndでも発生するんだっけ? if (CurrentPhase == Phase.FirstPlaying) { CurrentPhase = Phase.FirstThinking; MyDocument.AddLog("押", Convert.ToDecimal((MyQuestionPlayer.CurrentPosition - CurrentQuestion.PlayPos).TotalSeconds)); } }
private static ItemBatchOperation CreateItem(string id) { MyDocument myDocument = new MyDocument() { id = id, Status = id }; return(new ItemBatchOperation(OperationType.Create, 0, new Cosmos.PartitionKey(id), id, cosmosDefaultJsonSerializer.ToStream(myDocument))); }
public void PerformAsynchronousFileAccess_Null() { using (NSUrl url = NSUrl.FromFilename(GetFileName())) using (var doc = new MyDocument(url)) { // NULL value is not documented by Apple but adding a // [NullAllowed] would throw an Objective-C exception (bad) Assert.Throws <ArgumentNullException> (() => doc.PerformAsynchronousFileAccess(null)); } }
public static IActionResult SetDoc([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] MyDocument doc) { var id = Guid.NewGuid().ToString(); Bucket.Value.Insert(id, doc); return(new OkObjectResult($"New document inserted with ID {id}")); }
/// <summary> /// constructor /// </summary> /// <param name="mydoc"> /// the data used in the sample /// </param> public CurtainForm(MyDocument mydoc) { m_mydocument = mydoc; InitializeComponent(); // initialize some controls manually InitializeCustomComponent(); // register the customized events RegisterEvents(); }
public void TestThatReferenceSetterThrowsArgumentNullExceptionIfValueIsEmpty() { var fixture = new Fixture(); var document = new MyDocument(fixture.CreateAnonymous <int>(), fixture.CreateAnonymous <string>(), fixture.CreateAnonymous <string>(), fixture.CreateAnonymous <string>()); Assert.That(document, Is.Not.Null); Assert.Throws <ArgumentNullException>(() => document.Reference = string.Empty); }
public void Save() { // This test may fail in the simulator, if the architecture of the simulator isn't the native one (say running x86_64 on an M1 machine), // so just skip this test for the simulator. TestRuntime.AssertIfSimulatorThenARM64(); using (NSUrl url = NSUrl.FromFilename(GetFileName())) { doc = new MyDocument(url); doc.Save(url, UIDocumentSaveOperation.ForCreating, OperationHandler); } }
public void can_persist_and_load_nested_types() { var doc1 = new MyDocument(); theSession.Store(doc1); theSession.SaveChanges(); var doc2 = theSession.Load <MyDocument>(doc1.Id); doc2.ShouldNotBeNull(); }
/// <summary> /// constructor /// </summary> /// <param name="mydoc"> /// the document of the sample /// </param> public CreateCurtainSystemDialog(MyDocument mydoc) { m_mydocument = mydoc; InitializeComponent(); // // initialize data // // by default, create the curtain system by reference array m_byFaceArray = false; }
public async Task ValidateInvalidDocumentSizeAsync() { BatchAsyncContainerExecutor executor = new BatchAsyncContainerExecutor(this.cosmosContainer, this.cosmosContainer.ClientContext, 50, 2); string id = Guid.NewGuid().ToString(); MyDocument myDocument = new MyDocument() { id = id, Status = id }; await Assert.ThrowsExceptionAsync <ArgumentException>(() => executor.ValidateOperationAsync(new ItemBatchOperation(OperationType.Replace, 0, new Cosmos.PartitionKey(id), id, cosmosDefaultJsonSerializer.ToStream(myDocument)))); }
public void AssertState(MyDocument expected, MyDocument actual) { if (expected == null) { Assert.IsNull(actual, "Expected document as null"); return; } Assert.IsNotNull(actual, "Expected document not null"); Assert.AreEqual(expected.Id, actual.Id); Assert.AreEqual(expected.MyProperty, actual.MyProperty); Assert.AreEqual(expected.GetType(), actual.GetType()); }
public ObserverExceptionWrappingChangeFeedObserverDecoratorTests() { this.observer = new Mock <ChangeFeedObserver <MyDocument> >(); this.changeFeedObserverContext = Mock.Of <ChangeFeedObserverContext>(); this.observerWrapper = new FeedProcessing.ObserverExceptionWrappingChangeFeedObserverDecorator <MyDocument>(this.observer.Object); var document = new MyDocument(); documents = new List <MyDocument> { document }; }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { // data verification if (null == commandData.Application.ActiveUIDocument) { return(Autodesk.Revit.UI.Result.Failed); } MyDocument mydocument = new MyDocument(commandData); // check whether the mass is kind of parallelepiped CurtainSystem.MassChecker checker = new CurtainSystem.MassChecker(mydocument); bool validMass = checker.CheckSelectedMass(); if (!validMass) { message = Properties.Resources.MSG_InvalidSelection; return(Result.Cancelled); } UI.CurtainForm curtainForm = null; TransactionGroup transactionGroup = new TransactionGroup(commandData.Application.ActiveUIDocument.Document); try { transactionGroup.Start("CurtainSystemOperation"); curtainForm = new UI.CurtainForm(mydocument); if (null != curtainForm && false == curtainForm.IsDisposed) { curtainForm.ShowDialog(); } transactionGroup.Commit(); } catch (System.Exception ex) { transactionGroup.RollBack(); message = ex.Message; return(Result.Failed); } finally { if (null != curtainForm && false == curtainForm.IsDisposed) { curtainForm.Dispose(); } } return(Autodesk.Revit.UI.Result.Succeeded); }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements) { MyDocument myDoc = new MyDocument(commandData); using (GridForm gridForm = new GridForm(myDoc)) { // The form is created successfully if (null != gridForm && false == gridForm.IsDisposed) { gridForm.ShowDialog(); } } return Autodesk.Revit.UI.Result.Succeeded; }
/// <summary> /// default constructor /// </summary> /// <param name="myDoc"> /// the document of the sample /// </param> public WallGeometry(MyDocument myDoc) { m_myDocument = myDoc; m_drawing = new WallDrawing(this); }
/// <summary> /// constructor /// </summary> /// <param name="geometry"> /// the referred parent geometry of the curtain grid /// </param> public GridDrawing(MyDocument myDoc, GridGeometry geometry) { m_myDocument = myDoc; if (null == geometry) { MessageBox.Show("Error! There's no grid information in the curtain wall."); } else { m_geometry = geometry; m_coordinates = new GridCoordinates(myDoc, this); m_uGridLines2D = new List<GridLine2D>(); m_vGridLines2D = new List<GridLine2D>(); m_boundLines2D = new List<GridLine2D>(); m_uLinePathList = new List<GraphicsPath>(); m_uSegLinePathListList = new List<List<GraphicsPath>>(); m_vSegLinePathListList = new List<List<GraphicsPath>>(); m_vLinePathList = new List<GraphicsPath>(); m_boundPath = new List<GraphicsPath>(); m_drawObject = new DrawObject(); } }
/// <summary> /// constructor /// </summary> /// <param name="myDoc"> /// the document of the sample /// </param> public GridGeometry(MyDocument myDoc) { m_myDocument = myDoc; m_commandData = myDoc.CommandData; m_activeDocument = myDoc.Document; m_gridProperties = new GridProperties(); //m_activeGrid = grid; m_drawing = new GridDrawing(myDoc, this); m_uGridLines = new List<CurtainGridLine>(); m_vGridLines = new List<CurtainGridLine>(); m_GridVertexesXYZ = new List<Autodesk.Revit.DB.XYZ>(); }
/// <summary> /// constructor /// </summary> /// <param name="myDoc"> /// the document of this sample /// </param> /// <param name="drawing"> /// the GridDrawing data used in the dialog /// </param> public GridCoordinates(MyDocument myDoc, GridDrawing drawing) { m_myDocument = myDoc; if (null == drawing) { MessageBox.Show("Error! There's no grid information in the curtain wall."); } m_drawing = drawing; drawing.Coordinates = this; }
/// <summary> /// constructor /// </summary> /// <param name="myDoc"> /// store the document of this sample /// </param> public GridForm(MyDocument myDoc) { m_myDocument = myDoc; if (null == m_myDocument.UIDocument) { this.Close(); } InitializeComponent(); InitializeCustomComponent(); }