public void Throws_when_type_conversion_would_overflow() { var generator = new InMemoryIntegerValueGenerator <byte>(0); for (var i = 1; i < 256; i++) { generator.Next(null); } Assert.Throws <OverflowException>(() => generator.Next(null)); }
public void Throws_when_type_conversion_would_overflow() { var generator = new InMemoryIntegerValueGenerator<byte>(); for (var i = 1; i < 256; i++) { generator.Next(); } Assert.Throws<OverflowException>(() => generator.Next()); }
public void Creates_values() { var generator = new InMemoryIntegerValueGenerator <int>(0); Assert.Equal(1, generator.Next(null)); Assert.Equal(2, generator.Next(null)); Assert.Equal(3, generator.Next(null)); Assert.Equal(4, generator.Next(null)); Assert.Equal(5, generator.Next(null)); Assert.Equal(6, generator.Next(null)); generator = new InMemoryIntegerValueGenerator <int>(0); Assert.Equal(1, generator.Next(null)); Assert.Equal(2, generator.Next(null)); }
public void Creates_values() { var generator = new InMemoryIntegerValueGenerator<int>(); Assert.Equal(1, generator.Next()); Assert.Equal(2, generator.Next()); Assert.Equal(3, generator.Next()); Assert.Equal(4, generator.Next()); Assert.Equal(5, generator.Next()); Assert.Equal(6, generator.Next()); generator = new InMemoryIntegerValueGenerator<int>(); Assert.Equal(1, generator.Next()); Assert.Equal(2, generator.Next()); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual InMemoryIntegerValueGenerator <TProperty> GetIntegerValueGenerator <TProperty>(IProperty property) { if (_integerGenerators == null) { _integerGenerators = new Dictionary <int, IInMemoryIntegerValueGenerator>(); } var propertyIndex = property.GetIndex(); if (!_integerGenerators.TryGetValue(propertyIndex, out var generator)) { generator = new InMemoryIntegerValueGenerator <TProperty>(propertyIndex); _integerGenerators[propertyIndex] = generator; foreach (var row in _rows.Values) { generator.Bump(row); } } return((InMemoryIntegerValueGenerator <TProperty>)generator); }
/// <summary> /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to /// the same compatibility standards as public APIs. It may be changed or removed without notice in /// any release. You should only use it directly in your code with extreme caution and knowing that /// doing so can result in application failures when updating to a new Entity Framework Core release. /// </summary> public virtual InMemoryIntegerValueGenerator <TProperty> GetIntegerValueGenerator <TProperty>(IProperty property) { if (_integerGenerators == null) { _integerGenerators = new Dictionary <int, IInMemoryIntegerValueGenerator>(); } // WARNING: The in-memory provider is using EF internal code here. This should not be copied by other providers. See #15096 var propertyIndex = EntityFrameworkCore.Metadata.Internal.PropertyBaseExtensions.GetIndex(property); if (!_integerGenerators.TryGetValue(propertyIndex, out var generator)) { generator = new InMemoryIntegerValueGenerator <TProperty>(propertyIndex); _integerGenerators[propertyIndex] = generator; foreach (var row in _rows.Values) { generator.Bump(row); } } return((InMemoryIntegerValueGenerator <TProperty>)generator); }