private static void MultipleSourceCachedCascade(System.Random Rand) { foreach (Employee3 Employee3 in 100.Times(x => Rand.NextClass <Employee3>())) { Employee3.Boss = Rand.NextClass <Employee3>(); using (Utilities.Profiler.Profiler Profiler = new Utilities.Profiler.Profiler("Multiple Source Cached Cascade Save")) { Employee3.Save(); } } for (int x = 0; x < 100; ++x) { using (Utilities.Profiler.Profiler Profiler = new Utilities.Profiler.Profiler("Multiple Source Cached Cascade All")) { Employee3.All().ForEach(y => { var Temp = y.Boss; }); } } for (int x = 0; x < 100; ++x) { using (Utilities.Profiler.Profiler Profiler = new Utilities.Profiler.Profiler("Multiple Source Cached Cascade Any")) { var Temp = Employee3.Any().Boss; } } for (int x = 0; x < 100; ++x) { using (Utilities.Profiler.Profiler Profiler = new Utilities.Profiler.Profiler("Multiple Source Cached Cascade Paged")) { Employee3.Paged().ForEach(y => { var Temp = y.Boss; }); } } }
private static void TestUnsupportedTypes() { // Verify that saving objects with invalid properties result in exceptions var employee2 = new Employee2 { Name = "Alan", Age = 31, TimeWithCompany = TimeSpan.FromDays(300) }; AssertExtensions.ExpectException(() => Context.Save(employee2), typeof(InvalidOperationException), "Type System.TimeSpan is unsupported, it cannot be instantiated"); var employee3 = new Employee3 { Name = "Alan", Age = 31, EmptyProperty = new EmptyType() }; AssertExtensions.ExpectException(() => Context.Save(employee3), typeof(InvalidOperationException), "Type AWSSDK_DotNet.IntegrationTests.Tests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); // Verify that objects that are invalid result in exceptions AssertExtensions.ExpectException(() => Context.Scan <TimeSpan>(), typeof(InvalidOperationException), "Type System.TimeSpan is unsupported, it cannot be instantiated"); AssertExtensions.ExpectException(() => Context.Scan <EmptyType>(), typeof(InvalidOperationException), "Type AWSSDK_DotNet.IntegrationTests.Tests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); }
private async Task TestUnsupportedTypes() { InvalidOperationException exception; // Verify that saving objects with invalid properties result in exceptions var employee2 = new Employee2 { Name = "Alan", Age = 31, TimeWithCompany = TimeSpan.FromDays(300) }; exception = await Assert.ThrowsAsync <InvalidOperationException>(() => SharedTestFixture.Context.SaveAsync(employee2)); Assert.Equal(exception.Message, "Type System.TimeSpan is unsupported, it cannot be instantiated"); var employee3 = new Employee3 { Name = "Alan", Age = 31, EmptyProperty = new EmptyType() }; exception = await Assert.ThrowsAsync <InvalidOperationException>(() => SharedTestFixture.Context.SaveAsync(employee3)); Assert.Equal(exception.Message, "Type Amazon.DNXCore.IntegrationTests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); // Verify that objects that are invalid result in exceptions exception = await Assert.ThrowsAsync <InvalidOperationException>(() => SharedTestFixture.Context.ScanAsync <TimeSpan>(new List <ScanCondition>(), null).GetNextSetAsync()); Assert.Equal(exception.Message, "Type System.TimeSpan is unsupported, it cannot be instantiated"); exception = await Assert.ThrowsAsync <InvalidOperationException>(() => SharedTestFixture.Context.ScanAsync <EmptyType>(new List <ScanCondition>(), null).GetNextSetAsync()); Assert.Equal(exception.Message, "Type Amazon.DNXCore.IntegrationTests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); }
private static async Task TestUnsupportedTypes() { // Verify that saving objects with invalid properties result in exceptions var employee2 = new Employee2 { Name = "Alan", Age = 31, TimeWithCompany = TimeSpan.FromDays(300) }; await AssertExtensions.ExpectExceptionAsync <InvalidOperationException>(Context.SaveAsync(employee2), "Type System.TimeSpan is unsupported, it cannot be instantiated"); var employee3 = new Employee3 { Name = "Alan", Age = 31, EmptyProperty = new EmptyType() }; await AssertExtensions.ExpectExceptionAsync <InvalidOperationException>(Context.SaveAsync(employee3), "Type CommonTests.IntegrationTests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); // Verify that objects that are invalid result in exceptions AssertExtensions.ExpectException <InvalidOperationException>(() => Context.ScanAsync <TimeSpan>(new ScanCondition[] {}), "Type System.TimeSpan is unsupported, it cannot be instantiated"); AssertExtensions.ExpectException <InvalidOperationException>(() => Context.ScanAsync <EmptyType>(new ScanCondition[] { }), "Type CommonTests.IntegrationTests.DynamoDB.DynamoDBTests+EmptyType is unsupported, it has no supported members"); }
// Демонстрация работы с полями и свойствами /* Среда Visual Studio предлагает фрагмент кода prop. * Если вы наберете слово prop и два раза нажмете клавишу <ТаЬ>, * то IDE-среда сгенерирует начальный код для нового автоматического свойства. * Затем с помощью клавиши <ТаЬ> можно циклически проходить по всем частям * определения и заполнять необходимые детали. Испытайте описанный прием.*/ public static void Demo() { // первый способ Employee1 emp1 = new Employee1(); emp1.Name = "Bob"; emp1.Id = 1; // второй способ Employee2 emp2 = new Employee2(); emp2.Name = "Jane"; emp2.Id = 2; // третий способ (делает тоже, что и первый) - с версии C# 3.0 Employee3 emp3 = new Employee3 { Name = "Ohhh...", Id = 666 }; }
private static void TestUnsupportedTypes() { // Verify that saving objects with invalid properties result in exceptions var employee2 = new Employee2 { Name = "Alan", Age = 31, TimeWithCompany = TimeSpan.FromDays(300) }; AutoResetEvent ars = new AutoResetEvent(false); Context.SaveAsync <Employee2>(employee2, (result) => { var exception = result.Exception; Assert.AreEqual(typeof(InvalidOperationException), exception.GetType()); ars.Set(); }, options); ars.WaitOne(); var employee3 = new Employee3 { Name = "Alan", Age = 31, EmptyProperty = new EmptyType() }; Context.SaveAsync <Employee3>(employee3, (result) => { var exception = result.Exception; Assert.AreEqual(typeof(InvalidOperationException), exception.GetType()); ars.Set(); }, options); ars.WaitOne(); // Verify that objects that are invalid result in exceptions ExpectException <InvalidOperationException>(() => Context.ScanAsync <TimeSpan>(new ScanCondition[] { })); ExpectException <InvalidOperationException>(() => Context.ScanAsync <EmptyType>(new ScanCondition[] { })); }