public async Task Should_update_an_existing_lot() { using (var store = NewDocumentStore()) { using (var session = store.OpenAsyncSession()) { var supplier = new Supplier {Id = "Suppliers-1"}; await SaveEntity(supplier, session); var lot = new Lot {Id = "lots/2015/3", Arrived = new DateTime(2015, 6, 5)}; await SaveEntity(lot, session); } using (var session = store.OpenAsyncSession()) { var lotDto = new LotDto {Id = "lots/2015/3", Arrived = new DateTime(2015, 6, 5), SupplierId = "Suppliers-1"}; var service = GetLotItemsService(session); await service.Save(lotDto); } using (var session = store.OpenAsyncSession()) { var service = GetLotItemsService(session); var actual = await service.GetLotById("lots/2015/3"); actual.SupplierId.Should().Be("Suppliers-1"); } } }
public async Task Should_save_a_laboratory_reading() { using (var store = NewDocumentStore()) { using (var session = store.OpenAsyncSession()) { // Arrange var lot = new Lot {Id = "lots/2015/1"}; await SaveEntity(lot, session); var dto = new RawMaterialLabReadingDto { Id = null, Date = new DateTime(2015, 4, 18), LotId = "lots/2015/1", RawMaterialAnalysis = new RawMaterialAnalysis { Moisture = 24.5, SampleSize = 1000.0, MeasurementPodre = 10, MeasurementChocha = 4, MeasurementUmbigo = 3 } }; // Act var service = GetRawMaterialLabReadingsService(session); var model = await service.Save(dto); // Assert model.Success.Should().BeTrue(); model.Message.Should().Be("Criou analisis de podre/chocha para lote 2015/1"); model.Entity.Id.Should().Be("RawMaterialLabReadings-1"); var actual = await session.LoadAsync<RawMaterialLabReading>(model.Entity.Id); actual.Date.Should().Be(new DateTime(2015, 4, 18)); actual.LotId.Should().Be("lots/2015/1"); actual.RawMaterialAnalysis.Moisture.Should().Be(24.5); actual.RawMaterialAnalysis.SampleSize.Should().Be(1000.0); actual.RawMaterialAnalysis.MeasurementPodre.Should().Be(10); actual.RawMaterialAnalysis.MeasurementChocha.Should().Be(4); actual.RawMaterialAnalysis.MeasurementUmbigo.Should().Be(3); actual.RawMaterialAnalysis.PercentPodre.Should().Be(10/1000.0); actual.RawMaterialAnalysis.PercentChocha.Should().Be(4/1000.0); actual.RawMaterialAnalysis.PercentUmbigo.Should().Be(3/1000.0); actual.AuditInfo.Username.Should().NotBeNullOrEmpty(); actual.AuditInfo.Updated.Should().BeCloseTo(DateTime.Now, 2000); } } }
public void UpdateAuditInfo_should_retrieve_username_from_principal() { // Arrange var service = new TestClass(null, CurrentUserPrincipal()); var actual = new Lot(); // Act service.TestUpdateAuditInfo(actual); // Assert actual.AuditInfo.Username.Should().Be("jeremyholt"); actual.AuditInfo.Updated.Should().BeCloseTo(DateTime.Now, 2000); }