コード例 #1
0
        public static FinRustDbContext Create()
        {
            var options = new DbContextOptionsBuilder <FinRustDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var context = new FinRustDbContext(options);

            context.Database.EnsureCreated();

            context.Customers.AddRange(new[] {
                new Customer {
                    CustomerId = 1, Name = "Adam Cogan"
                },
                new Customer {
                    CustomerId = 2, Name = "Jason Taylor"
                },
                new Customer {
                    CustomerId = 3, Name = "Brendan Richards"
                },
            });

            context.Visualizations.Add(new Visualization()
            {
                CustomerId = 1,
                Name       = "Visualization"
            });

            context.SaveChanges();

            return(context);
        }
コード例 #2
0
        public static void InitializeDbForTests(FinRustDbContext context)
        {
            context.Customers.Add(new Customer
            {
                CustomerId = 1,
                Name       = "Test Customer"
            });

            context.Customers.Add(new Customer
            {
                CustomerId = 2,
                Name       = "Test Customer 2"
            });

            context.SaveChanges();
        }
コード例 #3
0
        public FinRustDbContextTests()
        {
            _dateTime     = new DateTime(3001, 1, 1);
            _dateTimeMock = new Mock <IDateTime>();
            _dateTimeMock.Setup(m => m.Now).Returns(_dateTime);

            _userId = "00000000-0000-0000-0000-000000000000";
            _currentUserServiceMock = new Mock <ICurrentUserService>();
            _currentUserServiceMock.Setup(m => m.UserId).Returns(_userId);

            var options = new DbContextOptionsBuilder <FinRustDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            _sut = new FinRustDbContext(options, _currentUserServiceMock.Object, _dateTimeMock.Object);

            //Fill database with test objects

            _sut.SaveChanges();
        }
コード例 #4
0
 public GetCustomersListQueryHandlerTests(QueryTestFixture fixture)
 {
     _context = fixture.Context;
     _mapper  = fixture.Mapper;
 }
コード例 #5
0
 public CommandTestBase()
 {
     _context = FinRustContextFactory.Create();
 }
コード例 #6
0
        public static void Destroy(FinRustDbContext context)
        {
            context.Database.EnsureDeleted();

            context.Dispose();
        }