Ejemplo n.º 1
0
        public async Task Should_Create_Account_Settings()
        {
            // Arrange
            _fixture.StartScope();

            var testAccount = (TestAccountProvider)_fixture.GetService <ICurrentAccountProvider>();

            testAccount.Id = Guid.NewGuid();

            var initialCount = await _fixture.CountAsync <AccountSetting>();

            var request = new UpdateSetting.Request
            {
                TargetCalories = 11.11M
            };

            // Act
            await _fixture.SendAsync(request);

            var finalCount = await _fixture.CountAsync <AccountSetting>();

            // Assert
            Assert.Equal(0, initialCount);
            Assert.Equal(1, finalCount);
        }
Ejemplo n.º 2
0
        public async Task Should_Get_Meal_Index_Without_Filter()
        {
            _fixture.StartScope();

            // Arrange-TestAccount
            var testAccount = (TestAccountProvider)_fixture.GetService <ICurrentAccountProvider>();

            {   // Arrange-Account
                var request = new Api.Features.Account.Create.Request
                {
                    Email    = _fixture.GetEmail(),
                    Password = Guid.NewGuid().ToString()
                };
                await _fixture.SendAsync(request);

                testAccount.Id =
                    (await _fixture.ExecuteDbContextAsync(db => db.Accounts.SingleOrDefaultAsync(x => x.Email == request.Email))).Id;
            }

            {   // Arrange-AccountSetting
                var request = new Api.Features.Account.UpdateSetting.Request
                {
                    TargetCalories = 10
                };
                await _fixture.SendAsync(request);
            }

            {   // Arrange-MealList
                var request = new Create.Request
                {
                    Date     = DateTime.UtcNow.Date,
                    Time     = "11:11",
                    Text     = "string",
                    Calories = 3
                };
                await _fixture.SendAsync(request);

                request.Date = request.Date.AddDays(1);
                request.Text = "string";
                await _fixture.SendAsync(request);

                request.Date = request.Date.AddDays(1);
                request.Text = "string1";
                await _fixture.SendAsync(request);

                request.Date = request.Date.AddDays(1);
                request.Text = "string1";
                await _fixture.SendAsync(request);

                // Act
                var count =
                    await _fixture.CountAsync <Meal>();

                // Assert
                Assert.Equal(4, count);
            }

            {
                // Arrange
                var request = new Index.Request
                {
                    PageSize = 100
                };

                // Act
                var response = await _fixture.SendAsync(request);

                // Assert
                Assert.NotNull(response);
                Assert.Equal(4, response.Items.Count);
            }
        }