Ejemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <SalesReasonRepository> > loggerMoc = SalesReasonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesReasonRepositoryMoc.GetContext();
            var repository = new SalesReasonRepository(loggerMoc.Object, context);

            var entity = new SalesReason();
            await repository.Create(entity);

            var record = await context.Set <SalesReason>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <SalesReasonRepository> > loggerMoc = SalesReasonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesReasonRepositoryMoc.GetContext();
            var repository = new SalesReasonRepository(loggerMoc.Object, context);

            SalesReason entity = new SalesReason();

            context.Set <SalesReason>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.SalesReasonID);

            record.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <SalesReasonRepository> > loggerMoc = SalesReasonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesReasonRepositoryMoc.GetContext();
            var         repository       = new SalesReasonRepository(loggerMoc.Object, context);
            SalesReason entity           = new SalesReason();

            context.Set <SalesReason>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.SalesReasonID);

            SalesReason modifiedRecord = await context.Set <SalesReason>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Ejemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SalesReasonRepository> > loggerMoc = SalesReasonRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SalesReasonRepositoryMoc.GetContext();
            var         repository       = new SalesReasonRepository(loggerMoc.Object, context);
            SalesReason entity           = new SalesReason();

            context.Set <SalesReason>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new SalesReason());

            var modifiedRecord = context.Set <SalesReason>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }