public void VersionAdded_InvalidArgument_ThrowsException()
        {
            var ofa = new OptionalFieldAttribute();

            AssertExtensions.Throws <ArgumentException>(null, () => ofa.VersionAdded = 0);
            AssertExtensions.Throws <ArgumentException>(null, () => ofa.VersionAdded = -1);
        }
Example #2
0
        public void VersionAdded_Set_GetReturnsExpected(int value)
        {
            var attribute = new OptionalFieldAttribute()
            {
                VersionAdded = value
            };

            Assert.Equal(value, attribute.VersionAdded);
        }
 public void VersionAdded_Roundtrips()
 {
     var ofa = new OptionalFieldAttribute();
     Assert.Equal(1, ofa.VersionAdded);
     ofa.VersionAdded = 2;
     Assert.Equal(2, ofa.VersionAdded);
     ofa.VersionAdded = int.MaxValue;
     Assert.Equal(int.MaxValue, ofa.VersionAdded);
 }
        public void VersionAdded_Roundtrips()
        {
            var ofa = new OptionalFieldAttribute();

            Assert.Equal(1, ofa.VersionAdded);
            ofa.VersionAdded = 2;
            Assert.Equal(2, ofa.VersionAdded);
            ofa.VersionAdded = int.MaxValue;
            Assert.Equal(int.MaxValue, ofa.VersionAdded);
        }
Example #5
0
        public static int OptionalMemebrVersion(Type type, string member)
        {
            Debug.Assert(type.IsSerializable);
            MemberInfo[] members = type.GetMember(member, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly);

            Debug.Assert(members.Length == 1);
            object[] attributes = members[0].GetCustomAttributes(typeof(OptionalFieldAttribute), false);
            Debug.Assert(attributes.Length == 1);

            OptionalFieldAttribute attribute = attributes[0] as OptionalFieldAttribute;

            Debug.Assert(attribute != null);
            return(attribute.VersionAdded);
        }
Example #6
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddDbContext <DataContext>(opt => {
         opt.UseSqlite(Configuration.GetConnectionString("DefaultConnection"));
     });
     services.AddCors(OptionalFieldAttribute =>
     {
         OptionalFieldAttribute.AddPolicy("CorsPolicy", policy =>
         {
             policy.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:3000");
         });
     });
     services.AddMediatR(typeof(List.Handler).Assembly);
     services.AddControllers();
 }
Example #7
0
        public void VersionAdded_ValueLessThanZero_ThrowsArgumentException(int value)
        {
            var attribute = new OptionalFieldAttribute();

            AssertExtensions.Throws <ArgumentException>(null, () => attribute.VersionAdded = value);
        }
Example #8
0
        public void Ctor_Default()
        {
            var attribute = new OptionalFieldAttribute();

            Assert.Equal(1, attribute.VersionAdded);
        }
 public void VersionAdded_InvalidArgument_ThrowsException()
 {
     var ofa = new OptionalFieldAttribute();
     Assert.Throws<ArgumentException>(null, () => ofa.VersionAdded = 0);
     Assert.Throws<ArgumentException>(null, () => ofa.VersionAdded = -1);
 }