예제 #1
0
        /// <summary>
        /// Gets a mapping that can be used with NHibernate.
        /// </summary>
        /// <param name="additionalTypes">Additional Types that are to be added to the mapping, this is useful for adding your ApplicationUser class</param>
        /// <returns></returns>
        public static HbmMapping GetIdentityMappings(System.Type[] additionalTypes)
        {
            var baseEntityToIgnore = new[]
            {
                typeof(EntityWithTypedId<int>),
                typeof(EntityWithTypedId<string>)
            };

            // Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
            var allEntities = new List<System.Type> {
                typeof(IdentityUser),
                typeof(IdentityRole),
                typeof(IdentityUserLogin),
                typeof(IdentityUserClaim),
            };
            allEntities.AddRange(additionalTypes);

            var mapper = new ConventionModelMapper();
            DefineBaseClass(mapper, baseEntityToIgnore.ToArray());
            mapper.IsComponent((type, declared) => typeof(ValueObject).IsAssignableFrom(type));

               // Modified for NS: PIMS.Infrastructure.NHibernate.NHAspNetIdentity
            mapper.AddMapping<IdentityUserMap>();
            mapper.AddMapping<IdentityRoleMap>();
            mapper.AddMapping<IdentityUserClaimMap>();

            return mapper.CompileMappingFor(allEntities);
        }
        public void IterationTest()
        {
            var testValues = new[] {1, 2, 3};

            var enumerator = new List<int>(testValues.ToArray()).GetEnumerator();

            using(var enumeratorWrapper = new EnumeratorWrapper<string>(enumerator, value => value.ToString()))
            {
                foreach(var testValue in testValues)
                {
                    enumeratorWrapper.MoveNext();

                    Assert.AreEqual(testValue.ToString(CultureInfo.InvariantCulture), enumeratorWrapper.Current);
                }
            }
        }
예제 #3
0
        public void FindMinimumLatency_Case9()
        {
            // Assign
            var gamsrv = new Gamsrv();
            var lines = new[]
            {
                "25 40", "1 2 3 4 5 6 10 11 15 16 20 21 22 23 24 25",
                "1 2 10", "2 3 10", "3 4 10", "4 5 10", "1 6 10", "2 7 10", "6 7 10",
                "3 8 10", "7 8 10", "4 9 10", "8 9 10", "5 10 10", "9 10 10", "6 11 10",
                "7 12 10", "11 12 10", "8 13 10", "12 13 10", "9 14 10", "13 14 10",
                "10 15 10", "14 15 10", "11 16 10", "12 17 10", "16 17 10", "13 18 10",
                "17 18 10", "14 19 10", "18 19 10", "15 20 10", "19 20 10", "16 21 10",
                "17 22 10", "21 22 10", "18 23 10", "22 23 10", "19 24 10", "23 24 10",
                "20 25 10", "24 25 10"
            };
            long expected = 40;

            // Act
            var actual = gamsrv.FindMinimumLatency(lines.ToArray());

            // Assert
            Assert.AreEqual(expected, actual);
        }
 public void can_except()
 {
     var x = new[] { 1, 2 }.Except(new[] { 2 });
     Assert.AreEqual(1, x.ToArray()[0]);
 }
 public void cant_edit_IEnumerable_int()
 {
     IEnumerable<int> sut = new [] {1};
     sut.ToArray()[0] = 2;
     Assert.IsFalse(sut.SequenceEqual(new []{2}));
 }
		/// <summary>
		///   Simulate that a given key is pressed. (Down and up)
		/// </summary>
		public static void SimulateKeyPress( Key key )
		{
			var virtualKey = (ushort)KeyInterop.VirtualKeyFromKey( key );
			var keyPress = new []
			{
				new User32.Input
				{
					Type = User32.InputEventType.Keyboard,
					InputInformation = new User32.InputUnion
					{
						KeyboardInput = new User32.KeyboardInput
						{
							VirtualKey = virtualKey,
						}
					}
				},
				new User32.Input
				{
					Type = User32.InputEventType.Keyboard,
					InputInformation = new User32.InputUnion
					{
						KeyboardInput = new User32.KeyboardInput
						{
							VirtualKey = virtualKey,
							Flags = User32.KeyboardInputFlags.KeyUp
						}
					}
				}
			};

			uint succeededEvents = User32.SendInput( (uint)keyPress.Length, keyPress.ToArray(), User32.Input.Size );
			if ( keyPress.Length != 0 && succeededEvents != keyPress.Length )
			{
				MarshalHelper.ThrowLastWin32ErrorException();
			}
		}