public async Task Success()
        {
            // 前準備
            var tableName = _tableName;
            await _fixture.CreateTableAsync(tableName);

            await using var provider = _services.BuildServiceProvider();

            var scores = new (Guid id, NewScore score)[]
        public async Task Success()
        {
            // 前準備
            var tableName = _tableName;
            await _fixture.CreateTableAsync(tableName);

            await using var provider = _services.BuildServiceProvider();

            var logic = provider.GetRequiredService <Initializer>();

            // 実行
            await logic.Initialize(_ownerId);

            // 検証
            var common = provider.GetRequiredService <IScoreCommonLogic>();

            {
                // 楽譜データ
                var o = "sc:" + common.ConvertIdFromGuid(_ownerId);

                var request = new QueryRequest(tableName)
                              .SetNamesAndValue(new { o = o })
                              .SetKeyConditionExpression("#o = :o");

                var token    = new CancellationTokenSource(TimeSpan.FromSeconds(10));
                var response = await _amazonDynamoDb.QueryAsync(request, token.Token);

                Assert.Single(response.Items);
                Assert.Equal(o, response.Items[0]["o"].S);
                Assert.Equal("summary", response.Items[0]["s"].S);
                Assert.Equal("0", response.Items[0]["sc"].N);
                Assert.Equal("AAAAAAAAAAAAAAAAAAAAAA", response.Items[0]["l"].S);
            }

            {
                // 楽譜アイテムデータ
                var o = "si:" + common.ConvertIdFromGuid(_ownerId);

                var request = new QueryRequest(tableName)
                              .SetNamesAndValue(new { o = o })
                              .SetKeyConditionExpression("#o = :o");

                var token    = new CancellationTokenSource(TimeSpan.FromSeconds(10));
                var response = await _amazonDynamoDb.QueryAsync(request, token.Token);

                Assert.Single(response.Items);
                Assert.Equal(o, response.Items[0]["o"].S);
                Assert.Equal("summary", response.Items[0]["s"].S);
                Assert.Equal("0", response.Items[0]["c"].N);
                Assert.Equal("0", response.Items[0]["t"].N);
                Assert.Equal("AAAAAAAAAAAAAAAAAAAAAA", response.Items[0]["l"].S);
            }
        }
        public async Task Success()
        {
            // 前準備
            var tableName = _tableName;
            await _fixture.CreateTableAsync(tableName);

            await using var provider = _services.BuildServiceProvider();

            var initLogic = provider.GetRequiredService <Initializer>();

            await initLogic.Initialize(_ownerId);

            var creator = provider.GetRequiredService <ScoreCreator>();

            (Guid id, NewScore score)score = (new Guid("d2dca5cb-2640-49e4-87ce-cb47f5ba4072"), new NewScore()
            {
                Title = "test",
                Description = "テスト"
            });

            await creator.CreateAsync(_ownerId, score.id, score.score.Title, score.score.Description);

            var pages = new List <NewScorePage>()
            {
                new()
                {
                    ItemId     = new Guid("172e58ec-d002-4fe5-ad2f-89417ecb43a6"),
                    Page       = "page01",
                    ObjectName = "object_name01"
                }
            };

            var logic = provider.GetRequiredService <ScorePageAdder>();

            // 実行
            await logic.AddPagesAsync(_ownerId, score.id, pages);

            // 検証
            var common = provider.GetRequiredService <IScoreCommonLogic>();

            {
                var o = "sc:" + common.ConvertIdFromGuid(_ownerId);
                var s = common.ConvertIdFromGuid(score.id);

                var request = new QueryRequest(tableName)
                              .SetNamesAndValue(new { o = o, s = s })
                              .SetKeyConditionExpression("#o = :o and #s = :s");

                var token    = new CancellationTokenSource(TimeSpan.FromSeconds(10));
                var response = await _amazonDynamoDb.QueryAsync(request, token.Token);

                Assert.Single(response.Items);
                var item = response.Items[0];
                var data = item["d"].M;
                Assert.Equal("1", data["pc"].N);

                var pList = data["p"].L;
                Assert.Single(pList);

                var p = pList[0];
            }
        }
    }
Exemple #4
0
        public async Task Success()
        {
            // 前準備
            var tableName = _tableName;
            await _fixture.CreateTableAsync(tableName);

            await using var provider = _services.BuildServiceProvider();

            var initLogic = provider.GetRequiredService <Initializer>();

            await initLogic.Initialize(_ownerId);

            var logic = provider.GetRequiredService <ScoreCreator>();

            var score = new NewScore()
            {
                Title       = "test",
                Description = "テスト"
            };

            // 実行
            await logic.CreateAsync(_ownerId, score);

            // 検証
            var common = provider.GetRequiredService <IScoreCommonLogic>();

            {
                // 楽譜データ
                var o = "sc:" + common.ConvertIdFromGuid(_ownerId);
                var s = common.ConvertIdFromGuid(_commonLogic.DefaultNewGuid);

                var request = new QueryRequest(tableName)
                              .SetNamesAndValue(new { o = o, s = s })
                              .SetKeyConditionExpression("#o = :o and #s = :s");

                var token    = new CancellationTokenSource(TimeSpan.FromSeconds(10));
                var response = await _amazonDynamoDb.QueryAsync(request, token.Token);

                Assert.Single(response.Items);
                var item = response.Items[0];
                Assert.Equal(o, item["o"].S);
                Assert.Equal(s, item["s"].S);
                Assert.Equal("pr", item["as"].S);

                var data = item["d"].M;
                Assert.True(data["p"].IsLSet);
                Assert.Empty(data["p"].L);
                Assert.True(data["a"].IsLSet);
                Assert.Empty(data["a"].L);
                Assert.Equal("0", data["ac"].N);
                Assert.Equal("0", data["pc"].N);
                Assert.Equal("test", data["t"].S);
                Assert.Equal("テスト", data["d"].S);
            }

            {
                // 楽譜サマリ
                var o = "sc:" + common.ConvertIdFromGuid(_ownerId);
                var s = "summary";

                var request = new QueryRequest(tableName)
                              .SetNamesAndValue(new { o = o, s = s })
                              .SetKeyConditionExpression("#o = :o and #s = :s");

                var token    = new CancellationTokenSource(TimeSpan.FromSeconds(10));
                var response = await _amazonDynamoDb.QueryAsync(request, token.Token);

                Assert.Single(response.Items);
                var item = response.Items[0];
                Assert.Equal("1", item["sc"].N);
            }
        }