public void EarlierVersionRaisesVersionConflict() { var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; var details = ObjectMother.Create <Curve>(); details.Id = 1; var entity = ObjectMother.Create <Curve>(); entity.Id = 2; entity.AddDetails(details); repository.Setup(x => x.FindOne <Curve>(1)).Returns(entity); // Act service.Update(1, 1, contract); }
public void ValidContractAdded() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var identifier = new NexusId { SystemName = "Test", Identifier = "A" }; var message = new CreateMappingRequest { EntityId = 12, Mapping = identifier }; var system = new MDM.SourceSystem { Name = "Test" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; validatorFactory.Setup(x => x.IsValid(It.IsAny<CreateMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); mappingEngine.Setup(x => x.Map<NexusId, CurveMapping>(identifier)).Returns(mapping); var curve = new MDM.Curve(); repository.Setup(x => x.FindOne<MDM.Curve>(12)).Returns(curve); validatorFactory.Setup(x => x.IsValid(It.IsAny<object>(), It.IsAny<IList<IRule>>())).Returns(false); // Act var candidate = (CurveMapping)service.CreateMapping(message); // Assert Assert.AreSame(mapping, candidate); repository.Verify(x => x.Save(curve)); repository.Verify(x => x.Flush()); }
public void EarlierVersionRaisesVersionConflict() { var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); validatorFactory.Setup(x => x.IsValid(It.IsAny<MDM.Contracts.Curve>(), It.IsAny<IList<IRule>>())).Returns(true); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; var details = ObjectMother.Create<Curve>(); details.Id = 1; var entity = ObjectMother.Create<Curve>(); entity.Id = 2; entity.AddDetails(details); repository.Setup(x => x.FindOne<Curve>(1)).Returns(entity); // Act service.Update(1, 1, contract); }
public override void Execute() { ShortcutService.AddLine(ActionType.Delete, (LineModel)ProjectService.GetAllLines()[Guid]); CurveService.Close(); ProjectService.DeleteLine(Guid); ViewManager.ChangeView("HideEdit"); }
public void EntityNotFound() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var message = new CreateMappingRequest { EntityId = 12, Mapping = new NexusId { SystemName = "Test", Identifier = "A" } }; validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); // Act var candidate = service.CreateMapping(message); // Assert Assert.IsNull(candidate); }
public void UnsuccessfulMatchReturnsNotFound() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var list = new List <CurveMapping>(); repository.Setup(x => x.Queryable <CurveMapping>()).Returns(list.AsQueryable()); var request = new CrossMappingRequest { SystemName = "Endur", Identifier = "A", ValidAt = SystemTime.UtcNow(), TargetSystemName = "Trayport" }; // Act var contract = service.CrossMap(request); // Assert Assert.IsNotNull(contract, "Contract null"); Assert.IsFalse(contract.IsValid, "Contract valid"); Assert.AreEqual(ErrorType.NotFound, contract.Error.Type, "ErrorType difers"); }
public void EntityNotFound() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true); // Act var response = service.Update(1, 1, contract); // Assert Assert.IsNotNull(response, "Response is null"); Assert.IsFalse(response.IsValid, "Response is valid"); Assert.AreEqual(ErrorType.NotFound, response.Error.Type, "ErrorType differs"); }
public void ValidDetailsSaved() { const int mappingId = 12; // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // NB Don't put mappingId here - service assigns it var identifier = new NexusId { SystemName = "Test", Identifier = "A" }; var message = new AmendMappingRequest { MappingId = mappingId, Mapping = identifier, Version = 34 }; var start = new DateTime(2000, 12, 31); var finish = DateUtility.Round(SystemTime.UtcNow().AddDays(5)); var s1 = new SourceSystem { Name = "Test" }; var m1 = new CurveMapping { Id = mappingId, System = s1, MappingValue = "1", Version = BitConverter.GetBytes(34L), Validity = new DateRange(start, DateUtility.MaxDate) }; var m2 = new CurveMapping { Id = mappingId, System = s1, MappingValue = "1", Validity = new DateRange(start, finish) }; // NB We deliberately bypasses the business logic var entity = new MDM.Curve(); m1.Curve = entity; entity.Mappings.Add(m1); validatorFactory.Setup(x => x.IsValid(It.IsAny <AmendMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); repository.Setup(x => x.FindOne <CurveMapping>(mappingId)).Returns(m1); mappingEngine.Setup(x => x.Map <NexusId, CurveMapping>(identifier)).Returns(m2); // Act service.UpdateMapping(message); // Assert Assert.AreEqual(mappingId, identifier.MappingId, "Mapping identifier differs"); // Proves we have an update not an add Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs"); // NB Don't verify result of Update - already covered by CurveMappingFixture repository.Verify(x => x.Save(entity)); repository.Verify(x => x.Flush()); }
public void NullRequestErrors() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Act service.CrossMap(null); }
public void NullRequestErrors() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Act service.CrossMap(null); }
private void Update() { if (CurveService.IsEditorOpen()) { return; } if (EventSystem.current.IsPointerOverGameObject(-1)) { if (BrushService.GetBrushShape() == Shape.Line && _drawing) { ReleaseLine(); } _cursorLine.gameObject.SetActive(false); return; } DrawCursor(); if (Input.GetMouseButtonDown(0)) { CreateLine(); } if (Input.GetMouseButton(0) && _lineRenderer != null && BrushService.GetBrushShape() == Shape.Line) { Vector2 tmpFingerPos = _camera.ScreenToWorldPoint(Input.mousePosition); if (Vector2.Distance(tmpFingerPos, _fingerPositions[_fingerPositions.Count - 1]) > 0.1f) { UpdateLine(tmpFingerPos); } _drawing = true; } if (Input.GetMouseButtonUp(0)) { ReleaseLine(); } if (Input.GetAxis("Mouse ScrollWheel") > 0 && Input.GetKey(KeyCode.LeftShift)) { _initialRotation++; } if (Input.GetAxis("Mouse ScrollWheel") < 0 && Input.GetKey(KeyCode.LeftShift)) { _initialRotation--; } }
public void NullContractInvalid() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); validatorFactory.Setup(x => x.IsValid(It.IsAny<object>(), It.IsAny<IList<IRule>>())).Returns(false); // Act service.CreateMapping(null); }
public void NullContractInvalid() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); validatorFactory.Setup(x => x.IsValid(It.IsAny <object>(), It.IsAny <IList <IRule> >())).Returns(false); // Act service.CreateMapping(null); }
public void ValidContractAdded() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var identifier = new NexusId { SystemName = "Test", Identifier = "A" }; var message = new CreateMappingRequest { EntityId = 12, Mapping = identifier }; var system = new MDM.SourceSystem { Name = "Test" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); mappingEngine.Setup(x => x.Map <NexusId, CurveMapping>(identifier)).Returns(mapping); var curve = new MDM.Curve(); repository.Setup(x => x.FindOne <MDM.Curve>(12)).Returns(curve); validatorFactory.Setup(x => x.IsValid(It.IsAny <object>(), It.IsAny <IList <IRule> >())).Returns(false); // Act var candidate = (CurveMapping)service.CreateMapping(message); // Assert Assert.AreSame(mapping, candidate); repository.Verify(x => x.Save(curve)); repository.Verify(x => x.Flush()); }
public void ValidDetailsSaved() { const int mappingId = 12; // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // NB Don't put mappingId here - service assigns it var identifier = new NexusId { SystemName = "Test", Identifier = "A" }; var message = new AmendMappingRequest { MappingId = mappingId, Mapping = identifier, Version = 34 }; var start = new DateTime(2000, 12, 31); var finish = DateUtility.Round(SystemTime.UtcNow().AddDays(5)); var s1 = new SourceSystem { Name = "Test" }; var m1 = new CurveMapping { Id = mappingId, System = s1, MappingValue = "1", Version = BitConverter.GetBytes(34L), Validity = new DateRange(start, DateUtility.MaxDate) }; var m2 = new CurveMapping { Id = mappingId, System = s1, MappingValue = "1", Validity = new DateRange(start, finish) }; // NB We deliberately bypasses the business logic var entity = new MDM.Curve(); m1.Curve = entity; entity.Mappings.Add(m1); validatorFactory.Setup(x => x.IsValid(It.IsAny<AmendMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); repository.Setup(x => x.FindOne<CurveMapping>(mappingId)).Returns(m1); mappingEngine.Setup(x => x.Map<NexusId, CurveMapping>(identifier)).Returns(m2); // Act service.UpdateMapping(message); // Assert Assert.AreEqual(mappingId, identifier.MappingId, "Mapping identifier differs"); // Proves we have an update not an add Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs"); // NB Don't verify result of Update - already covered by CurveMappingFixture repository.Verify(x => x.Save(entity)); repository.Verify(x => x.Flush()); }
public void EntityNotFound() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; validatorFactory.Setup(x => x.IsValid(It.IsAny<MDM.Contracts.Curve>(), It.IsAny<IList<IRule>>())).Returns(true); // Act var response = service.Update(1, 1, contract); // Assert Assert.IsNotNull(response, "Response is null"); Assert.IsFalse(response.IsValid, "Response is valid"); Assert.AreEqual(ErrorType.NotFound, response.Error.Type, "ErrorType differs"); }
public void EntityNotFound() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var message = new CreateMappingRequest { EntityId = 12, Mapping = new NexusId { SystemName = "Test", Identifier = "A" } }; validatorFactory.Setup(x => x.IsValid(It.IsAny<CreateMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); // Act var candidate = service.CreateMapping(message); // Assert Assert.IsNull(candidate); }
public void VersionConflict() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var message = new AmendMappingRequest { MappingId = 12, Mapping = new NexusId { SystemName = "Test", Identifier = "A" }, Version = 34 }; var mapping = new CurveMapping { Curve = new MDM.Curve() { Timestamp = BitConverter.GetBytes(25L) } }; // var <%= EntityName.ToLower() %> = new MDM.<%= EntityName %>(); // <%= EntityName.ToLower() %>.AddDetails(new <%= EntityName %>Details() { Timestamp = BitConverter.GetBytes(25L) }); // var mapping = new <%= EntityName %>Mapping { <%= EntityName %> = <%= EntityName.ToLower() %> }; validatorFactory.Setup(x => x.IsValid(It.IsAny <AmendMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); repository.Setup(x => x.FindOne <CurveMapping>(12)).Returns(mapping); // Act service.UpdateMapping(message); }
public void ValidContractIsSaved() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var curve = new Curve(); var contract = new MDM.Contracts.Curve(); validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true); mappingEngine.Setup(x => x.Map <MDM.Contracts.Curve, Curve>(contract)).Returns(curve); // Act var expected = service.Create(contract); // Assert Assert.AreSame(expected, curve, "Curve differs"); repository.Verify(x => x.Add(curve)); repository.Verify(x => x.Flush()); }
public void SuccessMatch() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Domain details var system = new MDM.SourceSystem { Name = "Endur" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; var targetSystem = new MDM.SourceSystem { Name = "Trayport" }; var targetMapping = new CurveMapping { System = targetSystem, MappingValue = "B", IsDefault = true }; var curve = new MDM.Curve { Id = 1, Timestamp = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 } }; //Curve.AddDetails(details); curve.ProcessMapping(mapping); curve.ProcessMapping(targetMapping); // Contract details var targetIdentifier = new NexusId { SystemName = "Trayport", Identifier = "B" }; mappingEngine.Setup(x => x.Map <CurveMapping, NexusId>(targetMapping)).Returns(targetIdentifier); var list = new List <CurveMapping> { mapping }; repository.Setup(x => x.Queryable <CurveMapping>()).Returns(list.AsQueryable()); var request = new CrossMappingRequest { SystemName = "Endur", Identifier = "A", TargetSystemName = "trayport", ValidAt = SystemTime.UtcNow(), Version = 0 }; // Act var response = service.CrossMap(request); var candidate = response.Contract; // Assert Assert.IsNotNull(response, "Contract null"); Assert.IsNotNull(candidate, "Mapping null"); Assert.AreEqual(1, candidate.Mappings.Count, "Identifier count incorrect"); Assert.AreSame(targetIdentifier, candidate.Mappings[0], "Different identifier assigned"); }
public void ValidDetailsSaved() { var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); // Contract var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var identifier = new MDM.Contracts.NexusId { SystemName = "Test", Identifier = "A" }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; contract.Identifiers.Add(identifier); // Domain var system = new SourceSystem { Name = "Test" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; var d1 = ObjectMother.Create <Curve>(); d1.Id = 1; d1.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 }; var entity = ObjectMother.Create <Curve>(); entity.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 }; entity.AddDetails(d1); var d2 = ObjectMother.Create <Curve>(); var range = new DateRange(new DateTime(2012, 1, 1), DateTime.MaxValue); validatorFactory.Setup(x => x.IsValid(It.IsAny <CreateMappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); validatorFactory.Setup(x => x.IsValid(It.IsAny <MDM.Contracts.Curve>(), It.IsAny <IList <IRule> >())).Returns(true); repository.Setup(x => x.FindOne <Curve>(1)).Returns(entity); mappingEngine.Setup(x => x.Map <MDM.Contracts.CurveDetails, Curve>(cd)).Returns(d2); mappingEngine.Setup(x => x.Map <MDM.Contracts.SystemData, DateRange>(nexus)).Returns(range); mappingEngine.Setup(x => x.Map <MDM.Contracts.NexusId, CurveMapping>(identifier)).Returns(mapping); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Act service.Update(1, 74, contract); // Assert Assert.AreEqual(0, d2.Mappings.Count, "Created entity mappings count differs"); Assert.AreEqual(0, d2.Id, "Created entity id differs"); Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs"); repository.Verify(x => x.Save(entity)); repository.Verify(x => x.Flush()); // Ok, hack the created one to align it d2.Id = entity.Id; foreach (var m in entity.Mappings) { d2.Mappings.Add(m); } // Should now be the same - avoid exposing what properties we have here Check(d2, entity); }
public void SuccessMatch() { // Arrange var validatorFactory = new Mock <IValidatorEngine>(); var mappingEngine = new Mock <IMappingEngine>(); var repository = new Mock <IRepository>(); var searchCache = new Mock <ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Domain details var start = new DateTime(1999, 12, 31); var finish = new DateTime(2020, 1, 1); var system = new SourceSystem { Name = "Endur" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; var curve = new Curve { Id = 1, Validity = new DateRange(start, finish) }; //Curve.AddDetails(details); curve.ProcessMapping(mapping); // Contract details var identifier = new MDM.Contracts.NexusId { SystemName = "Endur", Identifier = "A" }; var cdetails = new MDM.Contracts.CurveDetails(); mappingEngine.Setup(x => x.Map <CurveMapping, MDM.Contracts.NexusId>(mapping)).Returns(identifier); mappingEngine.Setup(x => x.Map <Curve, MDM.Contracts.CurveDetails>(curve)).Returns(cdetails); validatorFactory.Setup(x => x.IsValid(It.IsAny <MappingRequest>(), It.IsAny <IList <IRule> >())).Returns(true); var list = new List <CurveMapping> { mapping }; repository.Setup(x => x.Queryable <CurveMapping>()).Returns(list.AsQueryable()); var request = new MappingRequest { SystemName = "Endur", Identifier = "A", ValidAt = SystemTime.UtcNow(), Version = -1 }; // Act var response = service.Map(request); var candidate = response.Contract; // Assert mappingEngine.Verify(x => x.Map <CurveMapping, MDM.Contracts.NexusId>(mapping)); mappingEngine.Verify(x => x.Map <Curve, MDM.Contracts.CurveDetails>(curve)); repository.Verify(x => x.Queryable <CurveMapping>()); Assert.IsNotNull(candidate, "Contract null"); Assert.AreEqual(2, candidate.Identifiers.Count, "Identifier count incorrect"); // NB This is order dependent Assert.AreSame(identifier, candidate.Identifiers[1], "Different identifier assigned"); Assert.AreSame(cdetails, candidate.Details, "Different details assigned"); Assert.AreEqual(start, candidate.Nexus.StartDate, "Start date differs"); Assert.AreEqual(finish, candidate.Nexus.EndDate, "End date differs"); }
public override void Execute() { ProjectService.SelectLine(LineModel.Guid); CurveService.Close(); ViewManager.ChangeView("EditView"); }
public override async void Execute() { RTAnimationCurve rtAnimationCurve = CurveService.GetAnimationCurve(); rtAnimationCurve.ShowCurveEditor(); rtAnimationCurve.NewWindow(); AnimationCurve animationCurve = AnimationCurve.Constant(0, 1, 0.5f); switch (CurveType) { case CurveType.Animation: animationCurve = LineModel.KochLineProperty.AnimationCurve; break; case CurveType.Width: animationCurve = LineModel.WidthCurve; break; case CurveType.Lerp: animationCurve = LineModel.PhyllotaxisProperty.LerpInterpolationCurve; break; case CurveType.Scale: animationCurve = LineModel.PhyllotaxisProperty.ScaleInterpolationCurve; break; default: throw new ArgumentOutOfRangeException(); } rtAnimationCurve.Add(ref animationCurve); switch (CurveType) { case CurveType.Animation: case CurveType.Lerp: case CurveType.Scale: rtAnimationCurve.SetGradYRange(0, 1); break; case CurveType.Width: rtAnimationCurve.SetGradYRange(0, 0.5f); break; default: throw new ArgumentOutOfRangeException(); } rtAnimationCurve.SetGradXRange(0, 1); await TaskEx.WaitWhile(CurveService.IsEditorOpen); switch (CurveType) { case CurveType.Animation: LineModel.KochLineProperty.AnimationCurve = animationCurve; break; case CurveType.Width: LineModel.WidthCurve = animationCurve; break; case CurveType.Lerp: LineModel.PhyllotaxisProperty.LerpInterpolationCurve = animationCurve; break; case CurveType.Scale: LineModel.PhyllotaxisProperty.ScaleInterpolationCurve = animationCurve; break; default: throw new ArgumentOutOfRangeException(); } UpdateLineSignal.Dispatch(LineModel); }
public void ValidDetailsSaved() { var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); // Contract var cd = new MDM.Contracts.CurveDetails(); var nexus = new MDM.Contracts.SystemData { StartDate = new DateTime(2012, 1, 1) }; var identifier = new MDM.Contracts.NexusId { SystemName = "Test", Identifier = "A" }; var contract = new MDM.Contracts.Curve { Details = cd, Nexus = nexus }; contract.Identifiers.Add(identifier); // Domain var system = new SourceSystem { Name = "Test" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; var d1 = ObjectMother.Create<Curve>(); d1.Id = 1; d1.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 }; var entity = ObjectMother.Create<Curve>(); entity.Timestamp = new byte[] { 74, 0, 0, 0, 0, 0, 0, 0 }; entity.AddDetails(d1); var d2 = ObjectMother.Create<Curve>(); var range = new DateRange(new DateTime(2012, 1, 1), DateTime.MaxValue); validatorFactory.Setup(x => x.IsValid(It.IsAny<CreateMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); validatorFactory.Setup(x => x.IsValid(It.IsAny<MDM.Contracts.Curve>(), It.IsAny<IList<IRule>>())).Returns(true); repository.Setup(x => x.FindOne<Curve>(1)).Returns(entity); mappingEngine.Setup(x => x.Map<MDM.Contracts.CurveDetails, Curve>(cd)).Returns(d2); mappingEngine.Setup(x => x.Map<MDM.Contracts.SystemData, DateRange>(nexus)).Returns(range); mappingEngine.Setup(x => x.Map<MDM.Contracts.NexusId, CurveMapping>(identifier)).Returns(mapping); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Act service.Update(1, 74, contract); // Assert Assert.AreEqual(0, d2.Mappings.Count, "Created entity mappings count differs"); Assert.AreEqual(0, d2.Id, "Created entity id differs"); Assert.AreEqual(1, entity.Mappings.Count, "Mapping count differs"); repository.Verify(x => x.Save(entity)); repository.Verify(x => x.Flush()); // Ok, hack the created one to align it d2.Id = entity.Id; foreach (var m in entity.Mappings) { d2.Mappings.Add(m); } // Should now be the same - avoid exposing what properties we have here Check(d2, entity); }
public void UnsuccessfulMatchReturnsNotFound() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var list = new List<CurveMapping>(); repository.Setup(x => x.Queryable<CurveMapping>()).Returns(list.AsQueryable()); var request = new CrossMappingRequest { SystemName = "Endur", Identifier = "A", ValidAt = SystemTime.UtcNow(), TargetSystemName = "Trayport" }; // Act var contract = service.CrossMap(request); // Assert Assert.IsNotNull(contract, "Contract null"); Assert.IsFalse(contract.IsValid, "Contract valid"); Assert.AreEqual(ErrorType.NotFound, contract.Error.Type, "ErrorType difers"); }
public void SuccessMatch() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); // Domain details var system = new MDM.SourceSystem { Name = "Endur" }; var mapping = new CurveMapping { System = system, MappingValue = "A" }; var targetSystem = new MDM.SourceSystem { Name = "Trayport" }; var targetMapping = new CurveMapping { System = targetSystem, MappingValue = "B", IsDefault = true }; var curve = new MDM.Curve { Id = 1, Timestamp = new byte[] { 1, 0, 0, 0, 0, 0, 0, 0 } }; //Curve.AddDetails(details); curve.ProcessMapping(mapping); curve.ProcessMapping(targetMapping); // Contract details var targetIdentifier = new NexusId { SystemName = "Trayport", Identifier = "B" }; mappingEngine.Setup(x => x.Map<CurveMapping, NexusId>(targetMapping)).Returns(targetIdentifier); var list = new List<CurveMapping> { mapping }; repository.Setup(x => x.Queryable<CurveMapping>()).Returns(list.AsQueryable()); var request = new CrossMappingRequest { SystemName = "Endur", Identifier = "A", TargetSystemName = "trayport", ValidAt = SystemTime.UtcNow(), Version = 0 }; // Act var response = service.CrossMap(request); var candidate = response.Contract; // Assert Assert.IsNotNull(response, "Contract null"); Assert.IsNotNull(candidate, "Mapping null"); Assert.AreEqual(1, candidate.Mappings.Count, "Identifier count incorrect"); Assert.AreSame(targetIdentifier, candidate.Mappings[0], "Different identifier assigned"); }
public void VersionConflict() { // Arrange var validatorFactory = new Mock<IValidatorEngine>(); var mappingEngine = new Mock<IMappingEngine>(); var repository = new Mock<IRepository>(); var searchCache = new Mock<ISearchCache>(); var service = new CurveService(validatorFactory.Object, mappingEngine.Object, repository.Object, searchCache.Object); var message = new AmendMappingRequest { MappingId = 12, Mapping = new NexusId { SystemName = "Test", Identifier = "A" }, Version = 34 }; var mapping = new CurveMapping { Curve = new MDM.Curve() { Timestamp = BitConverter.GetBytes(25L) } }; // var <%= EntityName.ToLower() %> = new MDM.<%= EntityName %>(); // <%= EntityName.ToLower() %>.AddDetails(new <%= EntityName %>Details() { Timestamp = BitConverter.GetBytes(25L) }); // var mapping = new <%= EntityName %>Mapping { <%= EntityName %> = <%= EntityName.ToLower() %> }; validatorFactory.Setup(x => x.IsValid(It.IsAny<AmendMappingRequest>(), It.IsAny<IList<IRule>>())).Returns(true); repository.Setup(x => x.FindOne<CurveMapping>(12)).Returns(mapping); // Act service.UpdateMapping(message); }
private void MapServices() { #region Audio AudioPeerService audioPeerService = (contextView as GameObject)?.GetComponentInChildren <AudioPeerService>(); if (audioPeerService != null) { injectionBinder.Bind <IAudioPeerService>().ToValue(audioPeerService); } #endregion #region Brush BrushService brushService = (contextView as GameObject)?.GetComponentInChildren <BrushService>(); if (brushService != null) { injectionBinder.Bind <IBrushService>().ToValue(brushService); } #endregion #region Camera CameraService cameraService = (contextView as GameObject)?.GetComponentInChildren <CameraService>(); if (cameraService != null) { injectionBinder.Bind <ICameraService>().ToValue(cameraService); } #endregion #region MyRegion CurveService curveService = (contextView as GameObject)?.GetComponentInChildren <CurveService>(); if (curveService != null) { injectionBinder.Bind <ICurveService>().ToValue(curveService); } #endregion #region Draw DrawService drawService = (contextView as GameObject)?.GetComponentInChildren <DrawService>(); if (drawService != null) { injectionBinder.Bind <IDrawService>().ToValue(drawService); } #endregion #region ViewManager ViewManager viewManager = (contextView as GameObject)?.GetComponentInChildren <ViewManager>(); if (viewManager != null) { injectionBinder.Bind <IViewManager>().ToValue(viewManager); } #endregion #region Background BackgroundService backgroundService = (contextView as GameObject)?.GetComponentInChildren <BackgroundService>(); if (cameraService != null) { injectionBinder.Bind <IBackgroundService>().ToValue(backgroundService); } #endregion #region Project ProjectService projectService = (contextView as GameObject)?.GetComponentInChildren <ProjectService>(); if (cameraService != null) { injectionBinder.Bind <IProjectService>().ToValue(projectService); } #endregion #region Shortcut ShortcutService shortcutService = (contextView as GameObject)?.GetComponentInChildren <ShortcutService>(); if (shortcutService != null) { injectionBinder.Bind <IShortcutService>().ToValue(shortcutService); } #endregion #region Save SaveManager saveManager = (contextView as GameObject)?.GetComponentInChildren <SaveManager>(); if (shortcutService != null) { injectionBinder.Bind <ISaveManager>().ToValue(saveManager); } #endregion #region Recording RecordingService recordingService = (contextView as GameObject)?.GetComponentInChildren <RecordingService>(); if (recordingService != null) { injectionBinder.Bind <IRecordingService>().ToValue(recordingService); } #endregion }