示例#1
0
        public void StorageStoreTest()
        {
            var storage = MockRepository.GenerateStrictMock <IStorage>();

            storage.Expect(s => s.GetPersonByUserID(null)).IgnoreArguments().Return(null);

            storage.Replay();

            var storageStore = new StorageStore(storage);

            storage.VerifyAllExpectations();
            Assert.IsNotNull(storageStore);
        }
示例#2
0
        public void DeleteAppointmentTest()
        {
            var storage = MockRepository.GenerateMock <IStorage>();

            storage.Expect(s => s.DeleteAppointment(appointment));

            storage.Replay();

            var storageStore = new StorageStore(storage);

            storageStore.DeleteAppointment(appointment);

            storage.VerifyAllExpectations();
        }
示例#3
0
        public void AddAppointmentTest()
        {
            var storage = MockRepository.GenerateMock <IStorage>();

            storage.Expect(s => s.CreateAppointment(appointment.Title, appointment.StartTime, appointment.EndTime)).Return(appointment);
            storage.Stub(s => s.CreateAttendance(appointment, null)).Return(null);

            storage.Replay();

            var storageStore = new StorageStore(storage);

            storageStore.AddAppointment(appointment);

            storage.VerifyAllExpectations();
        }
示例#4
0
        public void GetDaysTest()
        {
            var day = DateTime.Now;

            var storage = MockRepository.GenerateMock <IStorage>();

            storage.Expect(s => s.GetAppointments(null)).Return(
                new List <Appointment> {
                new Appointment {
                    Title = "first", StartTime = day.AddDays(1), EndTime = day.AddDays(1).AddHours(1)
                },
                new Appointment {
                    Title = "second", StartTime = day.AddDays(2), EndTime = day.AddDays(2).AddHours(1)
                },
            });

            storage.Replay();

            var storageStore = new StorageStore(storage);

            var result = storageStore.GetDays(day);

            storage.VerifyAllExpectations();
        }
示例#5
0
        public override IEnumerable <EventData> Get(Guid correlationId)
        {
            // Create the table query.
            var rangeQuery = new TableQuery <EventDataTableEntity <EventData> >().Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(correlationId.ToString("N")))
                             );

            IEnumerable <EventData> query = CorrelationIdTableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
                                            .Select(eventData => eventData.EventData)
                                            .OrderBy(eventData => eventData.Timestamp);

            return(query.ToList());
        }
示例#6
0
        public override IEnumerable <IEvent <TAuthenticationToken> > Get(Type aggregateRootType, Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
        {
            string streamName = GenerateStreamName(aggregateRootType, aggregateId);

            // Create the table query.
            var rangeQuery = new TableQuery <EventDataTableEntity <EventData> >().Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(streamName))
                             );

            IEnumerable <EventData> query = TableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
                                            .Select(eventData => eventData.EventData)
                                            .Where(eventData => eventData.AggregateId == streamName && eventData.Version > fromVersion)
                                            .OrderByDescending(eventData => eventData.Version);

            if (useLastEventOnly)
            {
                query = query.AsQueryable().Take(1);
            }

            return(query
                   .Select(eventData => EventDeserialiser.Deserialise(eventData))
                   .ToList());
        }
        /// <summary>
        /// Get the latest <see cref="Snapshot"/> from storage.
        /// </summary>
        /// <returns>The most recent <see cref="Snapshot"/> of</returns>
        protected override Snapshot Get(Type aggregateRootType, string streamName)
        {
            // Create the table query.
            var rangeQuery = new TableQuery <DynamicTableEntity>().Where
                             (
                TableQuery.CombineFilters
                (
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(streamName)),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("AggregateId", QueryComparisons.Equal, streamName)
                )
                             );

            var      operationContext = new OperationContext();
            Snapshot result           = TableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
#pragma warning disable 0436
                                        .Select(eventData => EntityPropertyConverter.ConvertBack <EventData>(eventData.Properties, operationContext))
#pragma warning restore 0436
                                        .Where(eventData => eventData.AggregateId == streamName)
                                        .OrderByDescending(eventData => eventData.Version)
                                        .Take(1)
                                        .Select(EventDeserialiser.Deserialise)
                                        .SingleOrDefault();

            return(result);
        }
示例#8
0
 public EstoqueController(StorageStore storageStore)
 {
     _storageStore = storageStore;
 }
        /// <summary>
        /// Gets a collection of <see cref="IEvent{TAuthenticationToken}"/> for the <see cref="IAggregateRoot{TAuthenticationToken}"/> of type <paramref name="aggregateRootType"/> with the ID matching the provided <paramref name="aggregateId"/> from and including the provided <paramref name="fromVersionedDate"/> up to and including the provided <paramref name="toVersionedDate"/>.
        /// </summary>
        /// <param name="aggregateRootType"> <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> the <see cref="IEvent{TAuthenticationToken}"/> was raised in.</param>
        /// <param name="aggregateId">The <see cref="IAggregateRoot{TAuthenticationToken}.Id"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/>.</param>
        /// <param name="fromVersionedDate">Load events from and including from this <see cref="DateTime"/></param>
        /// <param name="toVersionedDate">Load events up-to and including from this <see cref="DateTime"/></param>
        public override IEnumerable <IEvent <TAuthenticationToken> > GetBetweenDates(Type aggregateRootType, Guid aggregateId, DateTime fromVersionedDate, DateTime toVersionedDate)
        {
            string streamName = GenerateStreamName(aggregateRootType, aggregateId);

            // Create the table query.
            var rangeQuery = new TableQuery <EventDataTableEntity <EventData> >().Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(streamName))
                             );

            IEnumerable <EventData> query = TableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
                                            .Select(eventData => eventData.EventData)
                                            .Where(eventData => eventData.AggregateId == streamName && eventData.Timestamp >= fromVersionedDate && eventData.Timestamp <= toVersionedDate)
                                            .OrderByDescending(eventData => eventData.Version);

            return(query
                   .Select(eventData => EventDeserialiser.Deserialise(eventData))
                   .ToList());
        }
        /// <summary>
        /// Get the latest <see cref="Snapshot"/> from storage.
        /// </summary>
        /// <returns>The most recent <see cref="Snapshot"/> of</returns>
        protected override Snapshot Get(Type aggregateRootType, string streamName)
        {
            // Create the table query.
            var rangeQuery = new TableQuery <EventDataTableEntity <EventData> >().Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(streamName))
                             );

            Snapshot result = TableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
                              .Select(eventData => eventData.EventData)
                              .Where(eventData => eventData.AggregateId == streamName)
                              .OrderByDescending(eventData => eventData.Version)
                              .Take(1)
                              .Select(EventDeserialiser.Deserialise)
                              .SingleOrDefault();

            return(result);
        }
示例#11
0
        /// <summary>
        /// Retrieves the data from Azure Storage using <see cref="TableStorageStore{TData,TCollectionItemData}.Collection"/>.
        /// </summary>
        public override IEnumerable <EntityTableEntity <TData> > GetByKey()
        {
            // Create the table query.
            var rangeQuery = Collection.Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(typeof(TData).FullName))
                             );

            IEnumerable <EntityTableEntity <TData> > results = ReadableSource.ExecuteQuery(rangeQuery);

            return(results);
        }
示例#12
0
 public HomeController(StorageStore storageStore)  //ILogger<HomeController> logger
 {
     //_logger = logger;
     _storageStore = storageStore;
 }
示例#13
0
 public CategoriasController(StorageStore storageStore)
 {
     _storageStore = storageStore;
 }
示例#14
0
        /// <summary>
        /// Gets a collection of <see cref="IEvent{TAuthenticationToken}"/> for the <see cref="IAggregateRoot{TAuthenticationToken}"/> of type <paramref name="aggregateRootType"/> with the ID matching the provided <paramref name="aggregateId"/>.
        /// </summary>
        /// <param name="aggregateRootType"> <see cref="Type"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/> the <see cref="IEvent{TAuthenticationToken}"/> was raised in.</param>
        /// <param name="aggregateId">The <see cref="IAggregateRoot{TAuthenticationToken}.Id"/> of the <see cref="IAggregateRoot{TAuthenticationToken}"/>.</param>
        /// <param name="useLastEventOnly">Loads only the last event<see cref="IEvent{TAuthenticationToken}"/>.</param>
        /// <param name="fromVersion">Load events starting from this version</param>
        public override IEnumerable <IEvent <TAuthenticationToken> > Get(Type aggregateRootType, Guid aggregateId, bool useLastEventOnly = false, int fromVersion = -1)
        {
            string streamName = GenerateStreamName(aggregateRootType, aggregateId);

            // Create the table query.
            var rangeQuery = new TableQuery <DynamicTableEntity>().Where
                             (
                TableQuery.CombineFilters
                (
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(streamName)),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("AggregateId", QueryComparisons.Equal, streamName)
                )
                             );

            var operationContext          = new OperationContext();
            IEnumerable <EventData> query = TableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
#pragma warning disable 0436
                                            .Select(eventData => EntityPropertyConverter.ConvertBack <EventData>(eventData.Properties, operationContext))
#pragma warning restore 0436
                                            .Where(eventData => eventData.AggregateId == streamName && eventData.Version > fromVersion)
                                            .OrderByDescending(eventData => eventData.Version);

            if (useLastEventOnly)
            {
                query = query.AsQueryable().Take(1);
            }

            return(query
                   .Select(eventData => EventDeserialiser.Deserialise(eventData))
                   .ToList());
        }
示例#15
0
 public LojasController(StorageStore storageStore)
 {
     _storageStore = storageStore;
 }
示例#16
0
        /// <summary>
        /// Get all <see cref="IEvent{TAuthenticationToken}"/> instances for the given <paramref name="correlationId"/>.
        /// </summary>
        /// <param name="correlationId">The <see cref="IMessage.CorrelationId"/> of the <see cref="IEvent{TAuthenticationToken}"/> instances to retrieve.</param>
        public override IEnumerable <EventData> Get(Guid correlationId)
        {
            // Create the table query.
            var rangeQuery = new TableQuery <DynamicTableEntity>().Where
                             (
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, StorageStore <object, object> .GetSafeStorageKey(correlationId.ToString("N")))
                             );

            var operationContext          = new OperationContext();
            IEnumerable <EventData> query = CorrelationIdTableStorageStore.ReadableSource.ExecuteQuery(rangeQuery)
#pragma warning disable 0436
                                            .Select(eventData => EntityPropertyConverter.ConvertBack <EventData>(eventData.Properties, operationContext))
#pragma warning restore 0436
                                            .OrderBy(eventData => eventData.Timestamp);

            return(query.ToList());
        }
示例#17
0
 public ProdutosController(StorageStore storageStore)
 {
     _storageStore = storageStore;
 }