Exemple #1
0
 public CrudServiceFacts(ServiceFixture fixture)
 {
     this.fixture        = fixture;
     this.service        = this.fixture.ServiceProvider.GetService <ICrudService <MockEntity> >();
     this.repositoryMock = this.fixture.ServiceProvider.GetService <Mock <IRepository <MockEntity> > >();
     this.unitOfWorkMock = this.fixture.ServiceProvider.GetService <Mock <IUnitOfWork> >();
 }
Exemple #2
0
 public LessonServiceFacts(ServiceFixture fixture)
 {
     this.fixture = fixture;
     this.service = this.fixture.ServiceProvider.GetService <ILessonService>();
     this.lessonRepositoryMock         = this.fixture.ServiceProvider.GetService <Mock <IRepository <Lesson> > >();
     this.lessonAttendeeRepositoryMock = this.fixture.ServiceProvider.GetService <Mock <IRepository <LessonAttendee> > >();
     this.unitOfWorkMock = this.fixture.ServiceProvider.GetService <Mock <IUnitOfWork> >();
 }
        public async Task GetMetricsWorksAsExpectedAsync(ScaleAction action, int currentWorkerCount, long targetCount)
        {
            var fixture  = new ServiceFixture(action, currentWorkerCount);
            var service  = fixture.ExternalScaleService;
            var response = await service.GetMetrics(fixture.GetMetricsRequest, fixture.ServerCallContext);

            Assert.Equal(targetCount, response.MetricValues.First().MetricValue_);
        }
        public async Task IsActiveWorksAsExpectedAsync(bool inputKeepWorkersAlive, bool expectedIsAlive)
        {
            int inputCurrentWorkerCount = 1;
            var fixture = new ServiceFixture(ScaleAction.AddWorker, inputCurrentWorkerCount, inputKeepWorkersAlive);
            var service = fixture.ExternalScaleService;

            expectedIsAlive = true; // TODO remove this line once white list implemented.
            Assert.Equal(expectedIsAlive, (await service.IsActive(fixture.ScaleObjectRef, fixture.ServerCallContext)).Result);
        }
        /// <summary>
        /// Init
        /// </summary>
        /// <param name="connectionStrong"></param>
        /// <exception cref="DatabaseException">Ignore.</exception>
        public void Init(string connectionStrong)
        {
            ServiceFixture serviceFixture = new ServiceFixture();

            _database = serviceFixture.ServiceProvider.GetRequiredService <IDatabase>();

            _database.InitializeAsync().Wait();

            _transaction = serviceFixture.ServiceProvider.GetRequiredService <ITransaction>();

            _transactionContext = _transaction.BeginTransactionAsync <Post>(System.Data.IsolationLevel.ReadUncommitted).Result;
        }
Exemple #6
0
        public CustomerServiceTest(ServiceFixture fixture) : base(fixture)
        {
            _customerRecords = new List <CustomerRecord>
            {
                new CustomerRecord
                {
                    FirstName = "Mary",
                    LastName  = "Smith",
                },

                new CustomerRecord
                {
                    FirstName = "John",
                    LastName  = "McDonald",
                },

                new CustomerRecord
                {
                    FirstName = "Rob",
                    LastName  = "McDonald",
                },

                new CustomerRecord
                {
                    FirstName = "Markson",
                    LastName  = "McDonald",
                },

                new CustomerRecord
                {
                    FirstName = "Jake",
                    LastName  = "McDonald",
                },

                new CustomerRecord
                {
                    FirstName = "Mark",
                    LastName  = "McPhil",
                },

                new CustomerRecord
                {
                    FirstName = "Susan",
                    LastName  = "McDonald",
                },
            };

            Fixture.Db.AddRange(_customerRecords);
        }
Exemple #7
0
        public void TestService()
        {
            var fixture = new ServiceFixture <IMemoService, MemoService>(this);

            //BDD тест (сценарий)
            fixture.For()

            //Допустим (предусловия)
            .GivenNothing()

            //Когда (тестируемые действия)
            .When(async service => await service.CreateMemos(2))

            //Тогда (проверка результатов)
            .ThenExpect <MemoId, UpdateMemo>(command => command.Document != null)
            .ThenExpect <MemoId, UpdateMemo>(command => command.Document != null);
        }
Exemple #8
0
        public MyFooServiceTest(ServiceFixture fixture) : base(fixture)
        {
            _myFooRecords = new List <MyFooRecord>
            {
                new MyFooRecord
                {
                    FirstName = "Mary",
                    LastName  = "Smith",
                },

                new MyFooRecord
                {
                    FirstName = "John",
                    LastName  = "McDonald",
                }
            };

            Fixture.Db.AddRange(_myFooRecords);
        }
Exemple #9
0
        /// <summary>
        /// PrepareDatabaseAsync
        /// </summary>
        /// <returns></returns>
        /// <exception cref="DatabaseException">Ignore.</exception>
        private static async System.Threading.Tasks.Task PrepareDatabaseAsync()
        {
            ServiceFixture serviceFixture = new ServiceFixture();

            IDatabase database = serviceFixture.ServiceProvider.GetRequiredService <IDatabase>();

            await database.InitializeAsync().ConfigureAwait(false);

            StringBuilder stringBuilder = new StringBuilder();

            for (int i = 0; i < 2000; ++i)
            {
                stringBuilder.Append('x');
            }

            string text = stringBuilder.ToString();

            List <Post> posts = new List <Post>();

            for (int i = 0; i < 5001; i++)
            {
                Post newItem = new Post {
                    Text = text, CreationDate = TimeUtil.UtcNowUnixTimeMilliseconds, LastChangeDate = TimeUtil.UtcNowUnixTimeMilliseconds
                };
                posts.Add(newItem);
            }

            ITransaction       transaction        = serviceFixture.ServiceProvider.GetRequiredService <ITransaction>();
            TransactionContext transactionContext = await transaction.BeginTransactionAsync <Post>().ConfigureAwait(false);

            try
            {
                await database.BatchAddAsync(posts, "", transactionContext).ConfigureAwait(false);

                await transaction.CommitAsync(transactionContext).ConfigureAwait(false);
            }
            catch
            {
                await transaction.RollbackAsync(transactionContext).ConfigureAwait(false);
            }
        }
Exemple #10
0
        public ProductServiceTest(ServiceFixture client)
            : base(client)
        {
            _productRecords = new List <ProductRecord>
            {
                new ProductRecord
                {
                    ProductCode = "APP",
                    ProductName = "Apple",
                    ListPrice   = 10.50m,
                    IsListed    = true,
                },

                new ProductRecord
                {
                    ProductCode = "BAN",
                    ProductName = "Banana",
                    ListPrice   = 30.99m,
                    IsListed    = true,
                },

                new ProductRecord
                {
                    ProductCode = "ONG",
                    ProductName = "Orange",
                    ListPrice   = 35.99m,
                    IsListed    = false,
                },

                new ProductRecord
                {
                    ProductCode = "STR",
                    ProductName = "Strawberry",
                    ListPrice   = 40.00m,
                    IsListed    = true,
                },
            };

            Fixture.Db.AddRange(_productRecords);
        }
Exemple #11
0
        public ProductServiceTest(ServiceFixture client)
            : base(client)
        {
            _productRecords = new List <ProductRecord>
            {
                new ProductRecord
                {
                    ProductCode = "APP",
                    ProductName = "Apple",
                    ListPrice   = 10.50m,
                },

                new ProductRecord
                {
                    ProductCode = "BAN",
                    ProductName = "Banana",
                    ListPrice   = 30.99m,
                },
            };

            Fixture.Db.AddRange(_productRecords);
        }
Exemple #12
0
 public DeleteSpending(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #13
0
 public GetTabs(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #14
0
        public OrderServiceTest(ServiceFixture fixture) : base(fixture)
        {
            _customerRecords = new List <CustomerRecord>
            {
                new CustomerRecord
                {
                    FirstName = "Mary2",
                    LastName  = "Smith2",
                },

                new CustomerRecord
                {
                    FirstName = "John2",
                    LastName  = "McDonald2",
                },

                new CustomerRecord
                {
                    FirstName = "Jake2",
                    LastName  = "McDonald2",
                }
            };

            Fixture.Db.AddRange(_customerRecords);

            _productRecords = new List <ProductRecord>
            {
                new ProductRecord
                {
                    ProductCode = "APP2",
                    ProductName = "Apple2",
                    ListPrice   = 102.50m,
                },

                new ProductRecord
                {
                    ProductCode = "BAN2",
                    ProductName = "Banana2",
                    ListPrice   = 302.99m,
                },

                new ProductRecord
                {
                    ProductCode = "ORG2",
                    ProductName = "Orange2",
                    ListPrice   = 102.50m,
                },

                new ProductRecord
                {
                    ProductCode = "MAN2",
                    ProductName = "Mango2",
                    ListPrice   = 500.99m,
                },
            };

            Fixture.Db.AddRange(_productRecords);

            _orderRecords = new List <OrderRecord>
            {
                new OrderRecord
                {
                    CustomerId    = _customerRecords[0].Id,
                    OrderStatusId = OrderStatus.Invoiced,

                    OrderItems = new List <OrderItemRecord>
                    {
                        new OrderItemRecord
                        {
                            ProductId = _productRecords[0].Id,
                            UnitPrice = _productRecords[0].ListPrice,
                            Quantity  = 30,
                            StatusId  = OrderItemStatus.NoStock,
                        },

                        new OrderItemRecord
                        {
                            ProductId = _productRecords[1].Id,
                            UnitPrice = _productRecords[1].ListPrice,
                            Quantity  = 60,
                            StatusId  = OrderItemStatus.OnOrder,
                        },
                    },
                },

                new OrderRecord
                {
                    CustomerId    = _customerRecords[1].Id,
                    OrderStatusId = OrderStatus.Shipped,

                    OrderItems = new List <OrderItemRecord>
                    {
                        new OrderItemRecord
                        {
                            ProductId = _productRecords[1].Id,
                            UnitPrice = _productRecords[1].ListPrice,
                            Quantity  = 40,
                            StatusId  = OrderItemStatus.Allocated,
                        },

                        new OrderItemRecord
                        {
                            ProductId = _productRecords[2].Id,
                            UnitPrice = _productRecords[2].ListPrice,
                            Quantity  = 50,
                            StatusId  = OrderItemStatus.Invoiced,
                        },
                    },
                },
            };

            Fixture.Db.AddRange(_orderRecords);
        }
Exemple #15
0
 public GetOrdersOfSpending(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #16
0
 public SettlementWorkflows(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #17
0
 public GetSettlement(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #18
0
 public PostProduct(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
 public GetConsumptionBetween(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #20
0
 public GetSettlements(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #21
0
 public GetProducts(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
 public ProfileServiceTestsBase(ServiceFixture serviceFixture)
     : base(serviceFixture)
 {
     ProfileService = GetService <IProfileService>();
 }
Exemple #23
0
 public GetProduct(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #24
0
 public DeleteOrder(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #25
0
 public GetOrders(ServiceFixture fixture) : base(fixture)
 {
 }
Exemple #26
0
 public GetSpendings(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #27
0
 public PostSettleTabs(ServiceFixture fixture) : base(fixture)
 {
     DeleteStream();
 }
Exemple #28
0
 public void Dispose()
 {
     TestFixture.Dispose();
     ServiceFixture.Dispose();
 }
Exemple #29
0
 public BbsBlsSignature2020SuiteTests(ServiceFixture serviceFixture)
 {
     Provider       = serviceFixture.Provider;
     LdProofService = Provider.GetRequiredService <ILinkedDataProofService>();
 }
Exemple #30
0
 public GetSpending(ServiceFixture fixture) : base(fixture)
 {
 }