public void CreatedByDefault() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; DateTime before = DateTime.Now.AddSeconds(-10).ToUniversalTime(); DateTime after = before.AddSeconds(+20); SubmitDataResponse response = webServiceClient.SubmitData(request); Assert.That(response, Is.Not.Null); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); InMemoryRecord inserted = DatabaseRecords[0]; Assert.That(inserted.GetFieldValue("CreatedBy", "null"), Is.EqualTo("User")); Assert.That(inserted.GetFieldValue("CreatedDateTime", DateTime.MinValue), Is.InRange(before, after)); }
public void GetAuditDataWithARecordWithNoChanges() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest submitRequest = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; webServiceClient.SubmitData(submitRequest); Assert.That(DatabaseRecords, Is.Not.Empty); int recordId = DatabaseRecords[0].RecordId; GetAuditDataRequest request = new GetAuditDataRequest { Credentials = CreateCredentials(), Filter = new GetAuditDataFilter { Location = location, Module = AmplaModules.Production, SetId = Convert.ToString(recordId) } }; GetAuditDataResponse response = webServiceClient.GetAuditData(request); Assert.That(response.RowSets, Is.Not.Empty); Assert.That(response.RowSets[0].Rows, Is.Empty); }
public void CreatedBySetInRequest() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); record.SetFieldValue("CreatedBy", "UnitTests"); record.SetFieldValue("CreatedDateTime", DateTime.Today); SubmitDataRequest request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse response = webServiceClient.SubmitData(request); Assert.That(response, Is.Not.Null); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); InMemoryRecord inserted = DatabaseRecords[0]; Assert.That(inserted.GetFieldValue("CreatedBy", "null"), Is.EqualTo("UnitTests")); Assert.That(inserted.GetFieldValue("CreatedDateTime", DateTime.MinValue), Is.EqualTo(DateTime.Today.ToUniversalTime())); }
public void GetAuditDataWithARecordWithChanges() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); record.SetFieldValue("Field 1", 150); SubmitDataRequest submitRequest = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; webServiceClient.SubmitData(submitRequest); Assert.That(DatabaseRecords, Is.Not.Empty); int recordId = DatabaseRecords[0].RecordId; InMemoryRecord updateRecord = new InMemoryRecord(ProductionViews.StandardView()) { Location = record.Location, Module = record.Module, RecordId = recordId }; updateRecord.SetFieldValue("Field 1", 200); SubmitDataRequest update = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { updateRecord.ConvertToSubmitDataRecord() } }; webServiceClient.SubmitData(update); GetAuditDataRequest request = new GetAuditDataRequest { Credentials = CreateCredentials(), Filter = new GetAuditDataFilter { Location = location, Module = AmplaModules.Production, SetId = Convert.ToString(recordId) } }; GetAuditDataResponse response = webServiceClient.GetAuditData(request); AssertAuditTableContains(response, location, recordId, "Field 1", "150", "200"); }
public void Update() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); InMemoryRecord update = record.Clone(); update.Fields.Clear(); update.Location = record.Location; update.Fields.Add(new FieldValue("New Field", "100")); SubmitDataRequest request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse response = webServiceClient.SubmitData(request); Assert.That(response.DataSubmissionResults, Is.Not.Null); Assert.That(response.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(response.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Insert)); Assert.That(response.DataSubmissionResults[0].SetId, Is.GreaterThan(100)); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); Assert.That(DatabaseRecords[0].Find("New Field"), Is.Null); update.RecordId = (int)response.DataSubmissionResults[0].SetId; request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { update.ConvertToSubmitDataRecord() } }; response = webServiceClient.SubmitData(request); Assert.That(response.DataSubmissionResults, Is.Not.Null); Assert.That(response.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(response.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Update)); Assert.That(response.DataSubmissionResults[0].SetId, Is.EqualTo(update.RecordId)); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); Assert.That(DatabaseRecords[0].Find("New Field"), Is.Not.Null); Assert.That(DatabaseRecords[0].Find("New Field").Value, Is.EqualTo("100")); }
public void GetDataReturnsLocation() { SimpleDataWebServiceClient webServiceClient = new SimpleDataWebServiceClient( database, configuration, new SimpleSecurityWebServiceClient("User")); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest submitRequest = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse submitResponse = webServiceClient.SubmitData(submitRequest); Assert.That(submitResponse.DataSubmissionResults, Is.Not.Null); Assert.That(submitResponse.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(submitResponse.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Insert)); Assert.That(submitResponse.DataSubmissionResults[0].SetId, Is.GreaterThan(100)); string recordId = Convert.ToString(submitResponse.DataSubmissionResults[0].SetId); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); Assert.That(DatabaseRecords[0].Location, Is.EqualTo(location)); GetDataRequest request = new GetDataRequest { Credentials = CreateCredentials(), Filter = new DataFilter { Location = record.Location, Criteria = new[] { new FilterEntry { Name = "Id", Value = recordId } } }, View = new GetDataView { Context = NavigationContext.Plant, Mode = NavigationMode.Location, Module = AmplaModules.Production }, Metadata = true, OutputOptions = new GetDataOutputOptions { ResolveIdentifiers = false }, }; GetDataResponse response = webServiceClient.GetData(request); AssertResponseContainsValue(response, "Duration", "90"); AssertResponseContainsValue(response, "Location", location); }
public void GetAllWithExistingRecord() { InMemoryRecord record = ProductionRecords.NewRecord(); record.Location = location; record.MarkAsNew(); int recordId = record.SaveTo(webServiceClient); Assert.That(recordId, Is.GreaterThan(0)); Assert.That(DatabaseRecords, Is.Not.Empty); IList <AreaValueModel> models = repository.GetAll(); Assert.That(models, Is.Not.Empty); Assert.That(models[0].Id, Is.EqualTo(recordId)); }
public void InsertInvalidLocation() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); record.Location = record.Location + ".Invalid"; SubmitDataRequest request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; Assert.Throws <FaultException>(() => webServiceClient.SubmitData(request)); }
public void GetViaRecord() { DateTime before = DateTime.Now.AddMinutes(-1); DateTime after = DateTime.Now.AddMinutes(+1); InMemoryRecord record = ProductionRecords.NewRecord(); record.Location = Locations[0]; int recordId = SaveRecord(record); Assert.That(recordId, Is.GreaterThan(0)); Assert.That(Records, Is.Not.Empty); LocationModel getModel = Repository.FindById(recordId); Assert.That(getModel.Sample, Is.InRange(before, after)); Assert.That(getModel.Location, Is.EqualTo(Locations[0])); }
public void GetWithZeroDuration() { DateTime before = DateTime.Now.AddMinutes(-1); DateTime after = DateTime.Now.AddMinutes(1); var record = ProductionRecords.NewRecord().MarkAsNew(); record.SetFieldValue("Duration", 0); int recordId = SaveRecord(record); Assert.That(Records, Is.Not.Empty); TimeSpanModel retrieved = Repository.FindById(recordId); Assert.That(retrieved, Is.Not.Null); Assert.That(retrieved.Id, Is.EqualTo(recordId)); Assert.That(retrieved.Sample, Is.InRange(before, after)); Assert.That(retrieved.Duration, Is.EqualTo(TimeSpan.FromMinutes(0))); }
public void FindByIdForDefaultModel() { InMemoryRecord record = ProductionRecords.NewRecord(); //record.SetFieldValue("Value", 100); //record.SetFieldValue("Area", "ROM"); record.Location = location; record.MarkAsNew(); int recordId = record.SaveTo(webServiceClient); Assert.That(recordId, Is.GreaterThan(0)); Assert.That(DatabaseRecords, Is.Not.Empty); AreaValueModel model = repository.FindById(recordId); Assert.That(model.Id, Is.EqualTo(recordId)); Assert.That(model.Value, Is.EqualTo(0)); Assert.That(model.Area, Is.EqualTo(null)); Assert.That(repository.FindById(recordId + 1), Is.Null); }
public void FindById() { InMemoryRecord record = ProductionRecords.NewRecord(); record.SetFieldValue("Value", 100); record.SetFieldValue("Area", "ROM"); record.Location = location; record.MarkAsNew(); int recordId = SaveRecord(record); Assert.That(recordId, Is.GreaterThan(0)); Assert.That(Records, Is.Not.Empty); AreaValueModel model = Repository.FindById(recordId); Assert.That(model.Id, Is.EqualTo(recordId)); Assert.That(model.Value, Is.EqualTo(100)); Assert.That(model.Area, Is.EqualTo("ROM")); Assert.That(Repository.FindById(recordId + 1), Is.Null); }
public void Insert() { SimpleDataWebServiceClient webServiceClient = Create(); InMemoryRecord record = ProductionRecords.NewRecord().MarkAsNew(); SubmitDataRequest request = new SubmitDataRequest { Credentials = CreateCredentials(), SubmitDataRecords = new[] { record.ConvertToSubmitDataRecord() } }; SubmitDataResponse response = webServiceClient.SubmitData(request); Assert.That(response.DataSubmissionResults, Is.Not.Null); Assert.That(response.DataSubmissionResults.Length, Is.EqualTo(1)); Assert.That(response.DataSubmissionResults[0].RecordAction, Is.EqualTo(RecordAction.Insert)); Assert.That(response.DataSubmissionResults[0].SetId, Is.GreaterThan(100)); Assert.That(DatabaseRecords.Count, Is.EqualTo(1)); }
protected override void OnSetUp() { base.OnSetUp(); id = AddExisingRecord(ProductionRecords.NewRecord()); }