コード例 #1
0
        public void ShouldComposeSnapshotOfExactNumberOfEvents()
        {
            // ARRANGE
            var eventRepository    = new SqliteEventRepository(_connectionString);
            var snapshotRepository = new SqliteSnapshotEventRepository(_connectionString);

            var factory        = new DefaultAggregateFactory();
            var aggregateStore = new AggregateRepository(eventRepository, factory, snapshotRepository);

            // Create a test aggregate.
            var aggregateId = CombGuid.Generate();
            var aggregate   = aggregateStore.GetById <IncrementingAggregate>(aggregateId);

            var snapshotSize       = aggregate.SnapshotSize;
            var numberOfTestEvents = 2 * snapshotSize + 1;

            // Send test events to the aggregate.
            Enumerable.Range(1, numberOfTestEvents)
            .ToList()
            .ForEach(x => aggregate.Tell(new IncrementingAggregate.Increment()));

            // ACT
            var orderedEvents   = aggregateStore.Save(aggregate);
            var snapshotVersion = snapshotRepository.GetVersionByAggregateId(aggregateId);
            var snapshotOffer   = (SnapshotOffer)snapshotRepository
                                  .GetSnapshotEventByAggregateIdAndVersion(aggregateId, snapshotVersion ?? 0);
            var newAggregate = aggregateStore.GetById <IncrementingAggregate>(aggregateId);
            var newState     = newAggregate.Ask <int>(new IncrementingAggregate.GetValue());

            // ASSERT
            Assert.AreEqual(numberOfTestEvents, orderedEvents.Length);
            Assert.AreEqual(numberOfTestEvents - 1, snapshotOffer.Version);
            Assert.AreEqual(numberOfTestEvents - 1, snapshotOffer.State);
            Assert.AreEqual(numberOfTestEvents, newState);
        }
コード例 #2
0
        static LoggingTests()
        {
            Exception ex;

            try
            { throw new Exception(); }
            catch (Exception e)
            { ex = e; }

            _logDictionary = new Dictionary <string, string>
            {
                { Log.GuidKey, CombGuid.NewCombGuid().ToString() },
                { Log.LevelKey, LoggingLevel.Emergency.ToString() },
                { Log.ExceptionTypeFullNameKey, "TestException" },
                { Log.InnerExceptionGuidsPrefix + 0, CombGuid.NewCombGuid().ToString() },
                { Log.InnerExceptionGuidsPrefix + 1, CombGuid.NewCombGuid().ToString() },
                { Log.InnerExceptionGuidsPrefix + 2, CombGuid.NewCombGuid().ToString() },
                { Log.MessageFormatKey, "A test log: {0}, {1}, {2}" },
                { Log.ParameterPrefix + 0, "Parameter 1" },
                { Log.ParameterPrefix + 1, "Parameter 2" },
                { Log.ParameterPrefix + 2, "Parameter 3" },
                { Log.StackTraceKey, ex.StackTrace },
                { Log.StoredProcedureKey, "spTestLog" },
                { Log.StoredProcedureLineKey, "123" },
                { Log.ThreadIDKey, "343" },
                { Log.ThreadNameKey, "Log Test Thread" },
                { "Some key", "Some value" },
                { "Some other key", "Some other value" },
            };
        }
コード例 #3
0
        public void Start(IServiceBus bus)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting SubscriptionClient on {0}", bus.Endpoint.Uri);
            }

            _bus = bus;

            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Getting endpoint for subscription service at {0}", SubscriptionServiceUri);
            }

            _subscriptionServiceEndpoint = _endpointFactory.GetEndpoint(SubscriptionServiceUri);

            VerifyClientAndServiceNotOnSameEndpoint();

            _localEndpoints.Add(_bus.Endpoint);
            _localEndpoints.Add(_bus.ControlBus.Endpoint);

            _clientId = CombGuid.Generate();
            _ready.Reset();

            ConnectToSubscriptionService(bus);

            WaitForSubscriptionServiceResponse();
        }
コード例 #4
0
ファイル: Document.cs プロジェクト: msjogren/Documently
        public Document(string title, DateTime utcCreated)
        {
            var @event = new DocumentMetaDataCreated(
                CombGuid.Generate(), title, DocumentState.Created, utcCreated);

            RaiseEvent(@event);
        }
        public async Task ShouldSuccesfullyInitializeDatabaseAndCollection()
        {
            // ARRANGE
            var eventOffset    = 0L;
            var projectionId   = CombGuid.Generate();
            var projectionType = "IntegrationTestProjection";

            // Query Model Repository (DocumentDB)
            var queryModelRepository = new DocumentDbQueryModelRepository(_database, _collection, _offerThroughput, _noOfPartitions, _endpoint, _authKey);

            queryModelRepository.Initialize();

            // Projection Metadata Repository (MSSQL);
            var projectionMetadataRepository = new SqlServerProjectionMetadataRepository(_sqlConnectionString);

            projectionMetadataRepository.InitializeProjection(projectionId, projectionType);

            // Dummy Query Model
            var queryModelId   = CombGuid.Generate();
            var testQueryModel = new TestQueryModel(queryModelId, "Hello Integration Test!");

            // Query Model Store
            var queryModelStore = new QueryModelStore(
                queryModelRepository,
                projectionMetadataRepository,
                eventOffset,
                projectionId);

            // ACT
            await queryModelStore.SaveQueryModel(testQueryModel);

            // ASSERT
        }
コード例 #6
0
        public void CalculateScoreShouldReturnTrueWhenHasDilyuseOfAnySubstance()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid patientGuid          = CombGuid.NewCombGuid();
                var  assessmentDefinition = Substitute.For <AssessmentDefinition>();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "3269979", "Test"), ItemType.Question, null),
                                      DrugUseFrequency.DailyOrAlmostDaily);

                var nidaAssessFurtherScoringEngine = new NidaAssessFurtherScoringEngine();
                nidaAssessFurtherScoringEngine.CalculateScore(assessment);

                // Verify
                var scoredEvent = events.FirstOrDefault(e => e.GetType() == typeof(AssessmentScoredEvent)) as AssessmentScoredEvent;
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(scoredEvent.Value.ToString(), "True");
            }
        }
コード例 #7
0
        private List <Entities.sys_category> GetCategories()
        {
            List <Entities.sys_category> list = new List <Entities.sys_category>();
            var xmlSiteMap = new XmlSiteMap();

            xmlSiteMap.LoadFrom(Path.Combine(_webHostEnvironment.ContentRootPath, "sitemap.xml"));
            xmlSiteMap.SiteMapNodes.ForEach(item =>
            {
                list.Add(new Entities.sys_category()
                {
                    id             = CombGuid.NewGuidAsString(),
                    name           = item.Name,
                    route_template = item.RouteTemplate ?? "",
                    code           = item.Code,
                    father_code    = item.FatherCode,
                    uid            = item.UID,
                    target         = item.Target ?? "",
                    is_menu        = item.IsMenu == "1" ? true : false,
                    sort           = item.Sort,
                    action         = item.Action ?? "",
                    controller     = item.Controller ?? "",
                    icon_class     = item.IconClass ?? "",
                    route_name     = item.RouteName ?? ""
                });
            });
            return(list);
        }
コード例 #8
0
        public void an_interface_based_message_is_published()
        {
            _receivedAnyRat = new Future <CorrelatedSwedishRat>();

            var details = new AccountDetails();

            _publisherBus = ServiceBusFactory.New(sbc =>
            {
                sbc.ReceiveFrom(details.BuildUri("When_publishing_correlated_interface_publisher"));
                sbc.SetPurgeOnStartup(true);
                sbc.UseAzureServiceBus();
                sbc.UseAzureServiceBusRouting();
            });

            _subscriberBus = ServiceBusFactory.New(sbc =>
            {
                sbc.ReceiveFrom(details.BuildUri("When_publishing_correlated_interface_subscriber"));
                sbc.SetPurgeOnStartup(true);
                sbc.Subscribe(s => s.Handler <CorrelatedSwedishRat>(_receivedAnyRat.Complete).Transient());
                sbc.UseAzureServiceBus();
                sbc.UseAzureServiceBusRouting();
            });

            // wait for the inbound transport to become ready before publishing
            _subscriberBus.Endpoint.InboundTransport.Receive(c1 => c2 => { }, 1.Milliseconds());

            correlationId = CombGuid.Generate();
            _publisherBus.Publish <CorrelatedSwedishRat>(new CorrImpl(correlationId, "meek"));

            _receivedAnyRat.WaitUntilCompleted(15.Seconds()).ShouldBeTrue();
        }
コード例 #9
0
ファイル: CombGuidTests.cs プロジェクト: zz110/osharp-ns20
        public void NewGuid_Test()
        {
            Guid     id = CombGuid.NewGuid();
            DateTime dt = CombGuid.GetDateFrom(id);

            DateTime.Now.Subtract(dt).ShouldBeLessThan(TimeSpan.FromSeconds(1));
        }
コード例 #10
0
        public async Task <IActionResult> Order()
        {
            var model = new OrderViewModel
            {
                NewOrder = new OrderModel
                {
                    OrderId     = CombGuid.Generate(),
                    SubmittedOn = DateTime.UtcNow
                },
                Errors = new List <string>()
            };

            try
            {
                await messageSession.Send(new SubmitOrder
                {
                    OrderId     = model.NewOrder.OrderId,
                    SubmittedOn = model.NewOrder.SubmittedOn
                });
            }
            catch (Exception e)
            {
                model.Errors.Add(e.Message);
            }

            return(View(model));
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Staff" /> class.
        /// </summary>
        /// <param name="organizationKey">The organization key.</param>
        /// <param name="name">The name.</param>
        public Staff(Guid organizationKey, PersonName name)
        {
            Check.IsNotNull(name, () => Name);

            Key = CombGuid.NewCombGuid();
            RaiseEvent(new StaffCreatedEvent(Key, Version, organizationKey, name));
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssessmentReminder" /> class.
        /// </summary>
        /// <param name="organizationKey">The organization key.</param>
        /// <param name="patientKey">The patient key.</param>
        /// <param name="createdByStaffKey">The created by staff key.</param>
        /// <param name="assessmentDefinitionKey">The assessment definition key.</param>
        /// <param name="title">The title.</param>
        /// <param name="start">The start.</param>
        /// <param name="description">The description.</param>
        /// <param name="reminderRecurrence">The reminder recurrence.</param>
        /// <param name="end">The end.</param>
        public AssessmentReminder(
            Guid organizationKey,
            Guid patientKey,
            Guid createdByStaffKey,
            Guid assessmentDefinitionKey,
            string title,
            DateTime start,
            string description,
            AssessmentReminderRecurrence reminderRecurrence,
            DateTime?end)
        {
            OrganizationKey = organizationKey;
            Key             = CombGuid.NewCombGuid();

            RaiseEvent(
                new AssessmentReminderCreatedEvent(
                    Key,
                    MessageType,
                    organizationKey,
                    patientKey,
                    createdByStaffKey,
                    assessmentDefinitionKey,
                    title,
                    start,
                    end ?? start,
                    description,
                    AssessmentReminderStatus.Default,
                    reminderRecurrence));
        }
コード例 #13
0
        IContainSagaData CreateNewSagaEntity(Type sagaType)
        {
            var sagaEntityType = Features.Sagas.GetSagaEntityTypeForSagaType(sagaType);

            if (sagaEntityType == null)
            {
                throw new InvalidOperationException("No saga entity type could be found for saga: " + sagaType);
            }

            var sagaEntity = (IContainSagaData)Activator.CreateInstance(sagaEntityType);

            sagaEntity.Id = CombGuid.Generate();

            TransportMessage physicalMessage;

            if (currentContext.TryGet(ReceivePhysicalMessageContext.IncomingPhysicalMessageKey, out physicalMessage))
            {
                sagaEntity.OriginalMessageId = physicalMessage.Id;

                if (physicalMessage.ReplyToAddress != null)
                {
                    sagaEntity.Originator = physicalMessage.ReplyToAddress.ToString();
                }
            }

            return(sagaEntity);
        }
コード例 #14
0
        public void Run()
        {
            var dict = new Dictionary <string, object>
            {
                { "KeyA", 101 },
                { "KeyB", Guid.NewGuid() },
                { "KeyC", CombGuid.NewComb() },
            };

            var json    = JsonConvertX.SerializeObject(dict);
            var newDict = JsonConvertX.DeserializeObject <Dictionary <string, object> >(json);

            Assert.AreEqual((int)dict["KeyA"], newDict.Deserialize <int>("KeyA"));
            Assert.AreEqual((Guid)dict["KeyB"], newDict.Deserialize <Guid>("KeyB"));
            Assert.AreEqual((CombGuid)dict["KeyC"], newDict.Deserialize <CombGuid>("KeyC"));

#if !NET40
            json    = SpanJson.JsonSerializer.Generic.Utf16.Serialize(dict);
            newDict = SpanJson.JsonSerializer.Generic.Utf16.Deserialize <Dictionary <string, object> >(json);

            Assert.AreEqual((int)dict["KeyA"], newDict.Deserialize <int>("KeyA"));
            Assert.AreEqual((Guid)dict["KeyB"], newDict.Deserialize <Guid>("KeyB"));
            Assert.AreEqual((CombGuid)dict["KeyC"], newDict.Deserialize <CombGuid>("KeyC"));
#endif
        }
コード例 #15
0
        public void Setup()
        {
            _repository = new InMemorySagaRepository <SimpleSaga>();
            var initiatePolicy = new InitiatingSagaPolicy <SimpleSaga, InitiateSimpleSaga>(x => x.CorrelationId, x => false);

            _sagaId       = CombGuid.Generate();
            _initiateSaga = new InitiateSimpleSaga {
                CorrelationId = _sagaId, Name = "Chris"
            };
            var context = _initiateSaga.ToConsumeContext();

            _repository.GetSaga(context, _sagaId,
                                (i, c) => InstanceHandlerSelector.ForInitiatedBy <SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy)
            .Each(x => x(context));

            _initiateOtherSaga = new InitiateSimpleSaga {
                CorrelationId = _otherSagaId, Name = "Dru"
            };

            _otherSagaId = Guid.NewGuid();
            context      = _initiateOtherSaga.ToConsumeContext();
            _repository.GetSaga(context, _otherSagaId,
                                (i, c) => InstanceHandlerSelector.ForInitiatedBy <SimpleSaga, InitiateSimpleSaga>(i), initiatePolicy)
            .Each(x => x(context));

            _observeSaga = new ObservableSagaMessage {
                Name = "Chris"
            };
        }
コード例 #16
0
        public void ShouldApplyScoredEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid defGuid     = CombGuid.NewCombGuid();
                Guid patientGuid = CombGuid.NewCombGuid();
                var  source      = new AssessmentInstance(defGuid, patientGuid, assessmentName);
                source.ScoreComplete(new CodedConcept(CodeSystems.Obhita, "dummayCode", ""), "result");

                // Verify
                Assert.AreEqual(2, events.Count);
                var scoredEvent = events[1];
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType());
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, "result");
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).ScoreCode.Code, "dummayCode");
                Assert.IsNull((scoredEvent as AssessmentScoredEvent).Guidance);
                Assert.AreEqual(2, source.Version);
            }
        }
コード例 #17
0
        public static IContainer Build(IContainer container)
        {
            container.Configure(cfg =>
            {
                //cfg.For(typeof(ISagaRepository<>))
                //    .Singleton()
                //    .Use(typeof(InMemorySagaRepository<>));

                cfg.For <ISagaRepository <NodeSetupSaga> >()
                .Singleton()
                .Use(context => new InMemorySagaRepository <NodeSetupSaga>());

                // Subscribers
                cfg.For <NodeSetupProvider>().Singleton().Use <NodeSetupProvider>();

                cfg.For <Guid>().Use(() => CombGuid.Generate());

                // Domain services
                cfg.For <NodeGraphManager>()
                .Singleton()
                .Use <NodeGraphManager>();

                // Services

                cfg.For <MonitorService>()
                .Singleton()
                .Use <MonitorService>();
            });

            return(container);
        }
コード例 #18
0
        public void ShouldApplyAddedToWorkflowEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid defGuid     = CombGuid.NewCombGuid();
                Guid patientGuid = CombGuid.NewCombGuid();
                var  source      = new AssessmentInstance(defGuid, patientGuid, assessmentName);
                Guid workflowKey = CombGuid.NewCombGuid();
                source.AddToWorkflow(workflowKey);

                // Verify
                Assert.AreEqual(2, events.Count);
                var addedToWorkflowEvent = events[1];
                Assert.IsNotNull(addedToWorkflowEvent);
                Assert.AreEqual(typeof(AssessmentAddedToWorkflowEvent), addedToWorkflowEvent.GetType());
                Assert.AreEqual((addedToWorkflowEvent as AssessmentAddedToWorkflowEvent).WorkflowKey, workflowKey);
                Assert.AreEqual(2, source.Version);
            }
        }
コード例 #19
0
        public void CalculateScoreShouldRaiseScoredEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                const int itemValue = 2;

                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid defGuid     = CombGuid.NewCombGuid();
                Guid patientGuid = CombGuid.NewCombGuid();
                var  assessment  = new AssessmentInstance(defGuid, patientGuid, "TestName");
                assessment.UpdateItem("", itemValue);

                var nidaSingleQuestionScreenerScoringEngine = new NidaSingleQuestionScreenerScoringEngine();
                nidaSingleQuestionScreenerScoringEngine.CalculateScore(assessment);

                // Verify
                Assert.AreEqual(3, events.Count);
                var scoredEvent = events[2];
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType());
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, itemValue);
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_1_and_up");
                Assert.AreEqual(3, assessment.Version);
            }
        }
コード例 #20
0
        public void ShouldApplyCreatedEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid defGuid     = CombGuid.NewCombGuid();
                Guid patientGuid = CombGuid.NewCombGuid();
                var  source      = new AssessmentInstance(defGuid, patientGuid, assessmentName);

                // Verify
                Assert.AreEqual(1, events.Count);
                var createdEvent = events[0];
                Assert.IsNotNull(createdEvent);
                Assert.AreEqual(typeof(AssessmentCreatedEvent), createdEvent.GetType());
                Assert.AreEqual((createdEvent as AssessmentCreatedEvent).PatientKey, patientGuid);
                Assert.AreEqual((createdEvent as AssessmentCreatedEvent).AssessmentName, assessmentName);
                Assert.AreEqual(1, source.Version);
            }
        }
コード例 #21
0
 /// <summary>
 /// 初始化一个<see cref="EntityBase{TKey}"/>类型的新实例
 /// </summary>
 protected EntityBase()
 {
     if (typeof(TKey) == typeof(Guid))
     {
         Id = CombGuid.NewGuid().CastTo <TKey>();
     }
 }
コード例 #22
0
        public void ShouldApplyItemAddedEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid defGuid     = CombGuid.NewCombGuid();
                Guid patientGuid = CombGuid.NewCombGuid();
                var  source      = new AssessmentInstance(defGuid, patientGuid, assessmentName);
                source.UpdateItem("", 0);

                // Verify
                Assert.AreEqual(2, events.Count);
                var itemUpdatedEvent = events[1];
                Assert.IsNotNull(itemUpdatedEvent);
                Assert.AreEqual(typeof(ItemUpdatedEvent), itemUpdatedEvent.GetType());
                Assert.AreEqual((itemUpdatedEvent as ItemUpdatedEvent).Value, 0);
                Assert.AreEqual(2, source.Version);
            }
        }
コード例 #23
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(NotValid());
            }
            (bool Status, string Message)res;
            var item = _mapper.Map <Entities.Sys_User>(SysUser);

            if (SysUser.Id != Guid.Empty)
            {
                res = _sysUserService.UpdateUser(SysUser, UserId);
            }
            else
            {
                item.Account      = item.Account.TrimSpace();
                item.Id           = CombGuid.NewGuid();
                item.CreationTime = DateTime.Now;
                item.Creator      = UserId;
                item.Salt         = EncryptorHelper.CreateSaltKey();
                item.Password     = (EncryptorHelper.GetMD5(item.Account + item.Salt));
                res = _sysUserService.AddUser(item);
            }
            AjaxData.Message = res.Message;
            AjaxData.Code    = res.Status ? 0 : 2001;
            if (res.Status)
            {
                _sysRoleService.SetUserRoles(item.Id, RoleIds, UserId);
            }
            return(Json(AjaxData));
        }
コード例 #24
0
        /// <summary>
        /// 接口初始化
        /// </summary>
        public void Install()
        {
            var xmlSiteMap = new XmlSiteMap();

            xmlSiteMap.LoadFrom(Path.Combine(_environment.ContentRootPath, "sitemap.xml"));
            List <Entities.sys_category> sysApis = new List <Entities.sys_category>();

            xmlSiteMap.SiteMapNodes.ForEach(item =>
            {
                sysApis.Add(new Entities.sys_category()
                {
                    id             = CombGuid.NewGuidAsString(),
                    name           = item.Name,
                    route_template = item.RouteTemplate ?? "",
                    code           = item.Code,
                    father_code    = item.FatherCode,
                    uid            = item.UID,
                    target         = item.Target ?? "",
                    is_menu        = item.IsMenu == "1" ? true : false,
                    sort           = item.Sort,
                    action         = item.Action ?? "",
                    controller     = item.Controller ?? "",
                    icon_class     = item.IconClass ?? "",
                    route_name     = item.RouteName ?? ""
                });
            });
            _sysCategoryService.Init(sysApis);
            _settingService.Init();
        }
コード例 #25
0
        public void CalculateScoreShouldRaiseScoredEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                var patientGuid          = CombGuid.NewCombGuid();
                var assessmentDefinition = Substitute.For <AssessmentDefinition> ();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), "true");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "2", "Test"), ItemType.Question, null), "false");

                var drugAbuseScreeningTestScoringEngine = new DrugAbuseScreeningTestScoringEngine();
                drugAbuseScreeningTestScoringEngine.CalculateScore(assessment);

                // Verify
                Assert.AreEqual(4, events.Count);
                var scoredEvent = events[3];
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType());
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, 1);
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_0_to_2");
                Assert.AreEqual(4, assessment.Version);
            }
        }
コード例 #26
0
 public CreateCustomerViewModel(IServiceBus bus, IEventAggregator eventAggregator)
 {
     _Bus             = bus;
     _EventAggregator = eventAggregator;
     Command          = new CreateNewCustomer(CombGuid.Generate(),
                                              "unknown", "unknown", "unknown", "unknown", "unknown", "305533333");
 }
コード例 #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Role" /> class.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="roleType">Type of the role.</param>
        public Role(string name, RoleType roleType = RoleType.UserDefined)
        {
            Check.IsNotNullOrWhitespace(name, () => Name);

            Key = CombGuid.NewCombGuid();
            RaiseEvent(new RoleCreatedEvent(Key, Version, name, roleType));
        }
コード例 #28
0
        /// <summary>
        /// 接口初始化
        /// </summary>
        public void Install()
        {
            var xmlSiteMap = new XmlSiteMap();

            xmlSiteMap.LoadFrom(Path.Combine(_environment.ContentRootPath, "sitemap.xml"));
            List <Entities.Sys_Category> sysApis = new List <Entities.Sys_Category>();

            xmlSiteMap.SiteMapNodes.ForEach(item =>
            {
                sysApis.Add(new Entities.Sys_Category()
                {
                    Id            = CombGuid.NewGuid(),
                    Name          = item.Name,
                    RouteTemplate = item.RouteTemplate ?? "",
                    Code          = item.Code,
                    FatherCode    = item.FatherCode,
                    UID           = item.UID,
                    Target        = item.Target ?? "",
                    IsMenu        = item.IsMenu ?? "",
                    Sort          = item.Sort,
                    Action        = item.Action ?? "",
                    Controller    = item.Controller ?? "",
                    IconClass     = item.IconClass ?? "",
                    RouteName     = item.RouteName ?? ""
                });
            });
            _sysCategoryService.Init(sysApis);
            _settingService.Init();
        }
コード例 #29
0
        public static EventData ToEventData(this object @event, string aggregateType, Guid aggregateId, int version)
        {
            var data         = JsonSerializer.Serialize(@event, SerializerSettings);
            var et           = @event.GetType();
            var eventName    = et.Name;
            var eventHeaders = new Dictionary <string, object>
            {
                {
                    "EventClrType", et.AssemblyQualifiedName
                }
            };
            var metadata = JsonSerializer.Serialize(eventHeaders, SerializerSettings);
            var eventId  = CombGuid.Generate();

            return(new EventData
            {
                Id = eventId,
                Created = DateTime.UtcNow,
                AggregateType = aggregateType,
                AggregateId = aggregateId,
                Version = version,
                EventName = eventName,
                Event = data,
                Metadata = metadata,
            });
        }
コード例 #30
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SystemAccount" /> class.
        /// </summary>
        /// <param name="organizationKey">The organization key.</param>
        /// <param name="identifier">The identifier.</param>
        /// <param name="email">The email.</param>
        public SystemAccount(Guid organizationKey, string identifier, Email email)
        {
            Check.IsNotNullOrWhitespace(identifier, () => Identifier);

            Key = CombGuid.NewCombGuid();
            RaiseEvent(new SystemAccountCreatedEvent(Key, Version, organizationKey, identifier, email));
        }