public void SearchModelNoByKeywordFilterByManufacturer_ModelNoContains_1Result() { _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository); _instrumentService.Create(Guid.NewGuid(), "Bird", "DPI601IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Fluke", "DruckDPI601", "None", "Digital Pressure Indicator", 0); var instruments = _instrumentService.SearchModelNoByKeywordFilterByManufacturer("dpi601", "Druck").ToList(); Assert.AreEqual(1, instruments.Count); _instrumentRepository.DeleteAll(); }
public void SearchByKeyword_ModelNoExactMatchCaseInsensitive_2Results() { _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository); _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI701IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Fluke", "FLK100", "None", "Digital Pressure Indicator", 0); var instruments = _instrumentService.SearchByKeyword("dpi601IS"); Assert.AreEqual(1, instruments.ToList().Count); _instrumentRepository.DeleteAll(); }
public void Create_InvalidIdSupplied_ArgumentExceptionThrown() { var id = Guid.Empty; var manufacturer = "Druck"; var modelNo = "DPI601IS"; var range = "Not Specified"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 20; _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>()); CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); }
public void SearchByKeyword_ManufacturerContains_2Results() { _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository); _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI701IS", "None", "Digital Pressure Indicator", 0); _instrumentService.Create(Guid.NewGuid(), "Fluke", "FLK100", "None", "Digital Pressure Indicator", 0); var instruments = _instrumentService.SearchByKeyword("Dru"); Assert.AreEqual(2, instruments.ToList().Count); _instrumentRepository.DeleteAll(); }
public void Create_ModelNoGreaterThan50Characters_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Druck"; var modelNo = new string('A', 51); var range = "Not Specified"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 20; _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>()); CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ModelNoTooLong)); }
public void Create_ManufacturerNotSupplied_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = String.Empty; var modelNo = "DPI601IS"; var range = "Not Specified"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 20; _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>()); CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ManufacturerRequired)); }
public void Create_AllocatedCalibrationTimeGreaterThan1000_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Druck"; var modelNo = "DPI601IS"; var range = "Not Specified"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 1001; _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>()); CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InvalidAllocatedCalibrationTime)); }
public void Edit_InvalidInstrumentId_ArgumentExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Fluke"; var modelNo = "21"; var range = "Range"; var description = "Digital Multimeter"; var allocatedCalibrationTime = 20; var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>(); instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(null); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub); EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); }
public void GetInstruments_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown() { try { var id = Guid.NewGuid(); var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>(); _instrumentService = InstrumentServiceFactory.Create( MockRepository.GenerateMock <IInstrumentRepository>(), TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Public)); _instrumentService.GetInstruments(); } catch (DomainValidationException dex) { _domainValidationException = dex; } Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance)); }
public void Edit_DescriptionGreaterThan50Characters_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Fluke"; var modelNo = "DPI601IS"; var range = "range"; var description = new string('a', 51); var allocatedCalibrationTime = 20; var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>(); instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id)); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub); EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.DescriptionTooLong)); }
public void Edit_ModelNoRequired_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Fluke"; var modelNo = String.Empty; var range = "Range"; var description = "Digital Multimeter"; var allocatedCalibrationTime = 20; var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>(); instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id)); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub); EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ModelNoRequired)); }
public void Edit_AllocatedCalibrationTimeGreaterThan1000_DomainValidationExceptionThrown() { var id = Guid.NewGuid(); var manufacturer = "Fluke"; var modelNo = "DPI601IS"; var range = "range"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 1001; var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>(); instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id)); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub); EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InvalidAllocatedCalibrationTime)); }
public void Create_ValidInstrumentDetails_InstrumentCreated() { var id = Guid.NewGuid(); var manufacturer = "Druck"; var modelNo = "DPI601IS"; var range = "Not Specified"; var description = "Digital Pressure Indicator"; var allocatedCalibrationTime = 20; var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>(); instrumentRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments(); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryMock); CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); instrumentRepositoryMock.VerifyAllExpectations(); Assert.AreEqual(id, _savedInstrument.Id); Assert.AreEqual(manufacturer, _savedInstrument.Manufacturer); Assert.AreEqual(modelNo, _savedInstrument.ModelNo); Assert.AreEqual(range, _savedInstrument.Range); Assert.AreEqual(description, _savedInstrument.Description); Assert.AreEqual(allocatedCalibrationTime, _savedInstrument.AllocatedCalibrationTime); }
public void Edit_ValidInstrumentDetails_InstrumentCreated() { var id = Guid.NewGuid(); var manufacturer = "Fluke"; var modelNo = "21"; var range = "Range"; var description = "Digital Multimeter"; var allocatedCalibrationTime = 20; var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>(); instrumentRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments(); instrumentRepositoryMock.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id)); _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryMock); EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime); instrumentRepositoryMock.VerifyAllExpectations(); Assert.AreEqual(manufacturer, _savedInstrument.Manufacturer); Assert.AreEqual(modelNo, _savedInstrument.ModelNo); Assert.AreEqual(range, _savedInstrument.Range); Assert.AreEqual(description, _savedInstrument.Description); Assert.AreEqual(allocatedCalibrationTime, _savedInstrument.AllocatedCalibrationTime); }
internal Instrument(Account owner, Guid id, QuotationBulk initQuotation, InstrumentServiceFactory factory) : base("Instrument", 15) { _owner = owner; this.Id = id; this.QuotationBulk = initQuotation; _orderCollector = new Lazy <OrderCollector>(() => factory.CreateOrderCollector(this)); _lotCalculator = new Lazy <LotCalculator>(() => factory.CreateLotCalculator(this)); _calculator = new Lazy <InstrumentCalculator>(() => factory.CreateInstrumentCalculator(this)); _riskRawData = new RiskData(null); _cuttingFee = new CuttingFee(this); _lastResetDay = BusinessItemFactory.Create <DateTime?>("LastResetDay", null, PermissionFeature.Sound, this); _id = BusinessItemFactory.Create("ID", id, PermissionFeature.Key, this); _accountId = BusinessItemFactory.Create("AccountID", owner.Id, PermissionFeature.Key, this); _resetItemHistoryDict = new BusinessRecordDictionary <DateTime, InstrumentResetItem>("ResetItemHistory", this); _currencyRate = this.DoGetCurrencyRate(null); _waitingForHitOrders = new CacheData <List <Order> >(_orderCollector.Value.CollectWaitingForHitOrders); _executedAndHasPositionOrders = new CacheData <List <Order> >(_orderCollector.Value.CollectExecutedAndHasPositionOrders); _totalBuyQuantity = new CacheData <decimal>(_lotCalculator.Value.CalculateBuyQuantity); _TotalSellQuantity = new CacheData <decimal>(_lotCalculator.Value.CalculateSellQuantity); _quotationManager = new QuotationManager(owner, this, initQuotation); }
internal PhysicalInstrument(Account owner, Guid id, QuotationBulk initQuotation, InstrumentServiceFactory factory) : base(owner, id, initQuotation, factory) { _physicalLotCalculator = this.LotCalculator as PhysicalLotCalculator; _physicalInstrumentCalculator = this.Calculator as PhysicalInstrumentCalculator; }
public void Setup() { _instrumentService = InstrumentServiceFactory.Create(); _domainValidationException = null; }