public void Probe(ProbeContext context)
        {
            var dbContext = _dbContextFactory.Create();

            try
            {
                context.Add("persistence", "entity-framework");
                context.Add("entities", dbContext.Model.GetEntityTypes().Select(type => type.Name).ToArray());
            }
            finally
            {
                dbContext.Dispose();
            }
        }
Exemple #2
0
 async Task <ChoirState> GetSaga(Guid id)
 {
     using (var dbContext = _sagaDbContextFactory.Create())
     {
         return(await dbContext.Set <ChoirState>().SingleOrDefaultAsync(x => x.CorrelationId == id));
     }
 }
Exemple #3
0
 async Task <ShoppingChore> GetSaga(Guid id)
 {
     using (var dbContext = _sagaDbContextFactory.Create())
     {
         var sagaInstance = dbContext.Set <ShoppingChore>().SingleOrDefault(x => x.CorrelationId == id);
         return(sagaInstance);
     }
 }
        public void Probe(ProbeContext context)
        {
            var dbContext = _dbContextFactory.Create();

            try
            {
                context.Add("persistence", "entity-framework");

                var objectContext = ((IObjectContextAdapter)dbContext).ObjectContext;
                var workspace     = objectContext.MetadataWorkspace;

                context.Add("entities", workspace.GetItems <EntityType>(DataSpace.SSpace).Select(x => x.Name).ToArray());
            }
            finally
            {
                dbContext.Dispose();
            }
        }
Exemple #5
0
        public async Task Test_Discarded_Missing_Saga_Instance_Is_Not_Persisted()
        {
            // arrange
            var sagaId = Guid.NewGuid();

            // act
            await Bus.Publish <TriggerSecond>(new
            {
                CorrelationId = sagaId,
                TestName      = "Test_Discarded_Missing_Saga_Instance_Is_Not_Persisted"
            });

            var wasDiscarded = await _discarded.Task;

            Assert.IsTrue(wasDiscarded);

            using (var dbContext = _sagaDbContextFactory.Create())
            {
                var result = dbContext.Set <SimpleState>().FirstOrDefault(x => x.CorrelationId == sagaId);
                // THE PROBLEM : the missing instance is not discarded and is persisted to the repository
                // This test fails
                Assert.IsNull(result);
            }
        }