Example #1
0
        public async Task ComplexTypeUpdate()
        {
            // Arrange
            var provider = await RestierTestHelpers.GetTestableInjectionContainer <LibraryApi, LibraryContext>();

            var api = provider.GetTestableApiInstance <LibraryApi>();

            var item = new DataModificationItem(
                "Readers",
                typeof(Employee),
                null,
                RestierEntitySetOperation.Update,
                new Dictionary <string, object> {
                { "Id", new Guid("53162782-EA1B-4712-AF26-8AA1D2AC0461") }
            },
                new Dictionary <string, object>(),
                new Dictionary <string, object> {
                { "Addr", new Dictionary <string, object> {
                      { "Zip", "332" }
                  } }
            });
            var changeSet = new ChangeSet(new[] { item });
            var sc        = new SubmitContext(api, changeSet);

            // Act
            var changeSetPreparer = api.GetApiService <IChangeSetInitializer>();
            await changeSetPreparer.InitializeAsync(sc, CancellationToken.None).ConfigureAwait(false);

            var person = item.Resource as Employee;

            // Assert
            person.Should().NotBeNull();
            person.Addr.Zip.Should().Be("332");
        }
        public async Task DI_CompareCurrentVersion_ToRC2()
        {
            var provider = await RestierTestHelpers.GetTestableInjectionContainer <LibraryApi, LibraryContext>();

            var result = DependencyInjectionTestHelpers.GetContainerContentsLog(provider);

            result.Should().NotBeNullOrEmpty();

            var baseline = File.ReadAllText("..//..//..//..//Microsoft.Restier.Tests.AspNet//Baselines/RC2-LibraryApi-ServiceProvider.txt");

            result.Should().Be(baseline);
        }
        public async Task ContainerContents_WriteOutput(string projectPath)
        {
            var provider = await RestierTestHelpers.GetTestableInjectionContainer <LibraryApi, LibraryContext>();

            var result   = DependencyInjectionTestHelpers.GetContainerContentsLog(provider);
            var fullPath = Path.Combine(projectPath, "..//Microsoft.Restier.Tests.AspNet//Baselines//RC2-LibraryApi-ServiceProvider.txt");

            Console.WriteLine(fullPath);

            if (!Directory.Exists(Path.GetDirectoryName(fullPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
            }
            File.WriteAllText(fullPath, result);
            Console.WriteLine($"File exists: {File.Exists(fullPath)}");
        }