コード例 #1
0
		public static IQueryable<ArtistForAlbum> WhereHasArtistParticipationStatus(this IQueryable<ArtistForAlbum> query, Artist artist, ArtistAlbumParticipationStatus participation) {

			if (participation == ArtistAlbumParticipationStatus.Everything || artist == null)
				return query;

			var musicProducerTypes = new[] {ArtistType.Producer, ArtistType.Circle, ArtistType.OtherGroup};

			if (musicProducerTypes.Contains(artist.ArtistType)) {

				var producerRoles = ArtistRoles.Composer | ArtistRoles.Arranger;

				switch (participation) {
					case ArtistAlbumParticipationStatus.OnlyMainAlbums:
						return query.Where(a => !a.IsSupport && ((a.Roles == ArtistRoles.Default) || ((a.Roles & producerRoles) != ArtistRoles.Default)) && a.Album.ArtistString.Default != ArtistHelper.VariousArtists);
					case ArtistAlbumParticipationStatus.OnlyCollaborations:
						return query.Where(a => a.IsSupport || ((a.Roles != ArtistRoles.Default) && ((a.Roles & producerRoles) == ArtistRoles.Default)) || a.Album.ArtistString.Default == ArtistHelper.VariousArtists);
					default:
						return query;
				}

			} else {

				switch (participation) {
					case ArtistAlbumParticipationStatus.OnlyMainAlbums:
						return query.Where(a => !a.IsSupport);
					case ArtistAlbumParticipationStatus.OnlyCollaborations:
						return query.Where(a => a.IsSupport);
					default:
						return query;
				}
				
			}

		}
コード例 #2
0
        public void OperandTypes()
        {
            var OneByteOperandTypes = new byte[0xff];
            var TwoByteOperandTypes = new byte[0x1f];

            var typeOfOpCode = typeof(OpCode);
            var reserved = new[] { "Prefix1", "Prefix2", "Prefix3", "Prefix4", "Prefix5", "Prefix6", "Prefix7", "Prefixref" };

            foreach (FieldInfo fi in typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static).Where(f => !reserved.Contains(f.Name)))
            {
                if (fi.FieldType != typeOfOpCode)
                {
                    continue;
                }

                OpCode opCode = (OpCode)fi.GetValue(null);
                var value = unchecked((ushort)opCode.Value);
                if (value < 0x100)
                {
                    OneByteOperandTypes[value] = (byte)opCode.OperandType;
                }
                else if ((value & 0xff00) == 0xfe00)
                {
                    TwoByteOperandTypes[value & 0xff] = (byte)opCode.OperandType;
                }
            }

            AssertEx.Equal(OneByteOperandTypes, InstructionOperandTypes.OneByte);
            AssertEx.Equal(TwoByteOperandTypes, InstructionOperandTypes.TwoByte);
        }
コード例 #3
0
 private void EatOptionValue(ISnapshot snapshot, ExpressionKind kind, ICSharpExpression optionValue)
 {
     var addableKinds = new[] { ExpressionKind.Target, ExpressionKind.Stub, ExpressionKind.Mock };
     if (addableKinds.Contains(kind))
     {
         snapshot.Add(kind, optionValue);
     }
 }
コード例 #4
0
 public void Init_Should_Apply_Entity_Channels_To_Aspect()
 {
     var expected = new[] {"one", "two", "three"};
     var e = new DefaultEntity("Test", expected).CreateLabelAspect("Label", 0, 0);
     var aspect = new LabelAspect();
     aspect.Init(e);
     Assert.True(aspect.Channels.All(s => expected.Contains(s)));
 }
コード例 #5
0
        /// <summary>
        /// Get total damge using the custom values provided by you in the spellmanager
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        public static float GetTotalDamage(this Obj_AI_Base target)
        {
            var slots = new[] {SpellSlot.Q, SpellSlot.W, SpellSlot.E, SpellSlot.R};
            var dmg = Player.Spells.Where(s => slots.Contains(s.Slot)).Sum(s => target.GetDamage(s.Slot));
            dmg += Orbwalker.CanAutoAttack ? Player.Instance.GetAutoAttackDamage(target) : 0f;

            return dmg;
        }
コード例 #6
0
 private static string GetNextAttributeToken(string attributeCollection, char closingBracketChar, ref int index)
 {
     var terminatingChars = new[] { ',', ' ', '\t', closingBracketChar };
     string nameValuePair = HtmlStringHelper.ExtractTokenFromTagString(attributeCollection, ref index,
         terminatingChars);
     if (terminatingChars.Contains(nameValuePair[nameValuePair.Length - 1]))
         nameValuePair = nameValuePair.Substring(0, nameValuePair.Length - 1);
     return nameValuePair;
 }
コード例 #7
0
ファイル: SelectManyTests.cs プロジェクト: spib/nhcontrib
        public void CanSelectManyWithAssociationInWhereClause()
        {
            int[] typeCodes = new[] { 5, 15, 100 };

            var query = session.Linq<Patient>().SelectMany(p => p.PatientRecords, (p, r) => r)
                .Where(r => r.Gender == Gender.Male && typeCodes.Contains(r.Type.TypeCode)).ToArray();

            Assert.AreEqual(2, query.Length);
        }
コード例 #8
0
        public void ValidEmailValidationTest()
        {
            var errorFieldNames = new[] { "EmailWithoutTld", "EmptyString", "SimpleText", "EmailWithPlusChar" }.ToList();
            var errors = ModelValidator.ValidateObject(new ExampleModel1()).Errors;
            Assert.That(errors.Count, Is.EqualTo(errorFieldNames.Count));

            Assert.That(errors.ToList().All(x => x.ErrorCode == ErrorCodes.EmailAddressIsNotValid.ToString()));
            Assert.That(errors.ToList().All(x => errorFieldNames.Contains(x.FieldName)));
        }
コード例 #9
0
		public void NullAndEmptyStringFailsRequiredTextValidationTest()
		{
			var errorFieldNames = new[] { "EmptyString", "NullString" }.ToList();
			var errors = ModelValidator.ValidateObject(new ExampleModel1()).Errors;
			Assert.That(errors.Count, Is.EqualTo(errorFieldNames.Count));

			Assert.That(errors.ToList().All(x => x.ErrorCode == ValidationErrorCodes.Required.ToString()));
			Assert.That(errors.ToList().All(x => errorFieldNames.Contains(x.FieldName)));
		}
コード例 #10
0
ファイル: Random.cs プロジェクト: run00/Utilities
        public void WhenEnumerableHasItems_ReturnsItemInEnumerable()
        {
            //Arrange
            var list = new [] {"Michael", "Bob", "Joe"};

            //Act
            var result = list.Random();

            //Assert
            Assert.IsTrue(list.Contains(result));
        }
コード例 #11
0
        public void ContainsTest()
        {
            //ARRANGE
            var list1 = new[] { "a", "aa", "aaa", "aaaa" };

            //ACT
            var contains = list1.Contains("bbb", x => x.Length);

            //ASSERT
            Assert.IsTrue(contains);
        }
コード例 #12
0
        public void Can_select_ints_using_list_contains()
        {
            var ints = new[] { 1, 2, 3 }.ToList();

            using (var db = OpenDbConnection())
            {
                db.Select<TestType>(x => ints.Contains(x.Id));

                Assert.That(db.GetLastSql(), Is.StringContaining("(1,2,3)"));
            }
        }
コード例 #13
0
        public void Can_select_ints_using_array_contains()
        {
            var ints = new[] { 1, 2, 3 };

            using (var db = OpenDbConnection())
            {
                db.Select<TestType>(x => ints.Contains(x.Id));

                Assert.That(db.GetLastSql(), Is.StringContaining("(@0,@1,@2)").
                                             Or.StringContaining("(:0,:1,:2)"));
            }
        }
コード例 #14
0
        internal static bool IsCommitCharacter(CompletionItem completionItem, char ch, string textTypedSoFar)
        {
            // TODO(cyrusn): Don't hardcode this in.  Suck this out of the user options.
            var commitCharacters = new[]
            {
                ' ', '{', '}', '[', ']', '(', ')', '.', ',', ':',
                ';', '+', '-', '*', '/', '%', '&', '|', '^', '!',
                '~', '=', '<', '>', '?', '@', '#', '\'', '\"', '\\'
            };

            return commitCharacters.Contains(ch);
        }
コード例 #15
0
ファイル: RefreshDatabase.cs プロジェクト: caiokf/smart-track
        public void Execute()
        {
            var refreshOn = new[]
            {
                BuildConfigurations.Debug.Description(),
                BuildConfigurations.TestsUnit.Description()
            };
            if (!refreshOn.Contains(appSettings.Configuration))
                return;

            persistenceConfiguration.RecreateDatabase();
        }
        public void GetUrls_should_return_urls_from_provider_that_is_passed_in()
        {
            var expected = new[] {new GoogleUrl(), new GoogleUrl()};

            var providerFake = new Mock<IGoogleUrlProvider>();
            providerFake.Setup(x => x.GetUrls())
                .Returns(expected);

            var provider = new GoogleSiteMapProvider(new[] {providerFake.Object});
            var results = provider.GetUrls();

            results.Count().ShouldEqual(2);
            results.ToList().ForEach(url => expected.Contains(url).ShouldBeTrue());
        }
コード例 #17
0
 private void ListBox_Drop(object sender, DragEventArgs e)
 {
     var vm = (ShellViewModel)this.DataContext;
     // get the image files from filelist
     if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
         string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
         string[] imageFormats = new[] {"jpg", "jpeg", "png", "gif"};
         var images = from img in files
                      where imageFormats.Contains(System.IO.Path.GetExtension(img).Substring(1).ToLower())
                      select img;
         foreach (string img in images) {
             _vm.UploadQueue.AddWork(new WorkItem<string, UploadedImage>(img));
         }
         _vm.UploadQueue.DoNext();
     }
 }
コード例 #18
0
        public void CompareWithServer()
        {
            var diffFileNames = new[] { "\\mt4\\udpcommandtranslator.mq4", "\\sounds\\error.wav" };

            var serverFiles = TestDataGenerator.GetServerFiles();
            var ownFiles = TestDataGenerator.GetOwnFiles();

            var diffs = ClientFileBrowser.CompareWithServer(serverFiles, ownFiles);

            Assert.AreEqual(diffFileNames.Length, diffs.Count, "Количество обновлённых файлов определено неверно");

            foreach (var diffFileName in diffs)
            {
                if (!diffFileNames.Contains(diffFileName.FileName))
                    Assert.Fail("не найден изменённый файл {0}", diffFileName);
            }
        }
        public void Overrides_all_methods()
        {
            var objectMethodNames = new[] { "ToString", "Equals", "GetHashCode", "GetType" };
            var properties = typeof(MissingPropertyConfiguration).GetProperties();
            var methodsNotOverridden = typeof(MissingPropertyConfiguration).GetMethods()
                .Where(
                    m => m.DeclaringType != typeof(MissingPropertyConfiguration)
                        && !objectMethodNames.Contains(m.Name)
                        && !properties.Any(p => p.GetAccessors().Contains(m)))
                .ToArray();

            Assert.False(
                methodsNotOverridden.Any(),
                string.Format(
                        "The following methods have not been overridden MissingPropertyConfiguration: {0}",
                        string.Join(", ", methodsNotOverridden.Select(m => m.Name))));
        }
コード例 #20
0
ファイル: FlurlClientTests.cs プロジェクト: llenroc/Flurl
		// check that for every FlurlClient extension method, we have an equivalent Url and string extension
		public void extension_methods_consistently_supported() {
			var fcExts = ReflectionHelper.GetAllExtensionMethods<FlurlClient>(typeof(FlurlClient).Assembly);
			var urlExts = ReflectionHelper.GetAllExtensionMethods<Url>(typeof(FlurlClient).Assembly);
			var stringExts = ReflectionHelper.GetAllExtensionMethods<string>(typeof(FlurlClient).Assembly);
			var whitelist = new[] { "GetCookies", "WithUrl" }; // cases where Url method of the same name was excluded intentionally

			foreach (var method in fcExts) {
				if (whitelist.Contains(method.Name))
					continue;

				if (!urlExts.Any(m => ReflectionHelper.AreSameMethodSignatures(method, m))) {
					Assert.Fail("No equivalent URL extension method found for FlurlClient.{0}", method.Name);
				}
				if (!stringExts.Any(m => ReflectionHelper.AreSameMethodSignatures(method, m))) {
					Assert.Fail("No equivalent string extension method found for FlurlClient.{0}", method.Name);
				}
			}
		}
コード例 #21
0
		public static MethodDeclarationSyntax WithAccessModifiers(this MethodDeclarationSyntax method, MethodAttributes methodAttributes)
		{
			if ((methodAttributes & (MethodAttributes.Public | MethodAttributes.Private | MethodAttributes.Family | MethodAttributes.Assembly)) == 0)
			{
				return method;
			}

			var kinds = new[] { SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.InternalKeyword };
			var tokens = method.Modifiers.Where(c => !kinds.Contains(c.Kind())).ToList();

			if ((methodAttributes & MethodAttributes.Public) != 0)
			{
				return method.WithModifiers(new SyntaxTokenList()
					.Add(SyntaxFactory.Token(SyntaxKind.PublicKeyword))
					.AddRange(tokens));
			}

			if ((methodAttributes & MethodAttributes.Family) != 0)
			{
				if ((methodAttributes & MethodAttributes.Assembly) != 0)
				{
					return method.WithModifiers(new SyntaxTokenList()
						.Add(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword))
						.Add(SyntaxFactory.Token(SyntaxKind.InternalKeyword))
						.AddRange(tokens));
				}

				if ((methodAttributes & MethodAttributes.Assembly) != 0)
				{
					return method.WithModifiers(new SyntaxTokenList()
						.Add(SyntaxFactory.Token(SyntaxKind.ProtectedKeyword))
						.AddRange(tokens));
				}
			}

			if ((methodAttributes & MethodAttributes.Private) != 0)
			{
				return method.WithModifiers(new SyntaxTokenList()
					.Add(SyntaxFactory.Token(SyntaxKind.PrivateKeyword))
					.AddRange(tokens));
			}

			return method.WithModifiers(new SyntaxTokenList().AddRange(tokens));
		}
コード例 #22
0
        private void SetTheme()
        {
            var themes = new[] {"white", "blackglass", "red", "clean", "light", "dark"};

            if (_version == ReCaptchaVersion.Version1)
            {
                switch (Theme.ToLower())
                {
                    case "light":
                        Theme = "white";
                        break;
                    case "dark":
                        Theme = "blackglass";
                        break;
                    default:
                        if (!themes.Contains(Theme.ToLower()))
                        {
                            Theme = "white";
                        }
                        break;
                }
            }
            else if (_version == ReCaptchaVersion.Version2)
            {
                switch (Theme.ToLower())
                {
                    case "clean":
                    case "red":
                    case "white":
                        Theme = "light";
                        break;
                    case "blackglass":
                        Theme = "dark";
                        break;
                    default:
                        if (!themes.Contains(Theme.ToLower()))
                        {
                            Theme = "light";
                        }
                        break;
                }
            }
        }
コード例 #23
0
        public void ReverseGeoCode_RadialSearch_ReturnsCorrectResults()
        {
            // Read a file with data with points in and around London in a 20Km radius
            var data = GeoFileReader.ReadExtendedGeoNames(@"testdata\test_GB.txt").ToArray();
            var rg = new ReverseGeoCode<ExtendedGeoName>(data);
            var center = rg.CreateFromLatLong(51.5286416, 0);   //Exactly at 0 longitude so we test left/right of prime meridian

            Assert.AreEqual(47, data.Length);   //File should contain 47 records total

            var expected_ids = new[] { 2640729, 2639577, 2642465, 2637627, 2633709, 2643339, 2634677, 2636503, 2652053, 2654710, 2643743, 2646003, 2643741, 2653941, 6690870, 2655775, 2651621, 2650497, 2656194, 2653266, 2648657, 2637433, 2652618, 2646057 };

            // Search from the/a center in London for all points in a 10Km radius
            var searchresults = rg.RadialSearch(center, 100000.0).ToArray();
            // Number of results should match length of expected_id array
            Assert.AreEqual(expected_ids.Length, searchresults.Length);
            // Check if each result is in the expected results array
            foreach (var r in searchresults)
                Assert.IsTrue(expected_ids.Contains(r.Id));
        }
コード例 #24
0
ファイル: BatchRegMessages.cs プロジェクト: stevesloka/bvcms
 private void Instruction(XContainer e)
 {
     foreach (var ee in e.Elements())
     {
         var instrutions = new[] { "Login", "Select", "Find", "Options", "Special", "Submit", "Sorry", };
         var nname = ee.Name.ToString();
         switch (nname)
         {
             case "ThankYouMessage":
                 os.ThankYouMessage = ee.Value;
                 break;
             case "Terms":
                 os.Terms = ee.Value;
                 break;
             default:
                 if(instrutions.Contains(nname))
                     Util.SetProperty(os, "Instruction" + nname, ee.Value);
                 break;
         }
     }
 }
コード例 #25
0
        public static string GetDatabaseNameFromFiles(string oldName)
        {
            var arr = oldName.Replace(".", "_").Split('_');
              if (arr.Length <= 1)
              {
            return oldName;
              }

              var lastSection = arr.Last();
              var secondLastSection = arr[arr.Length - 2];

              var doubleBarrel = string.Format("{0}_{1}", secondLastSection, lastSection);

              var knownDoubleBarrel = new[]
                                        {
                                            "ecm_dispatch", "reporting_secondary", "tracking_live", "tracking_history",
                                            "tracking_contact"
                                        };

              return knownDoubleBarrel.Contains(doubleBarrel) ? doubleBarrel : lastSection;
        }
        public void GetUrls_should_return_results_from_two_providers()
        {
            var firstSet = new[] {new GoogleUrl(), new GoogleUrl()};
            var firstProviderFake = new Mock<IGoogleUrlProvider>();
            firstProviderFake.Setup(x => x.GetUrls())
                .Returns(firstSet);

            var secondSet = new[] {new GoogleUrl()};
            var secondProviderFake = new Mock<IGoogleUrlProvider>();
            secondProviderFake.Setup(x => x.GetUrls())
                .Returns(secondSet);

            var provider = new GoogleSiteMapProvider(new[] {firstProviderFake.Object, secondProviderFake.Object});
            var results = provider.GetUrls();

            results.Count().ShouldEqual(3);

            results.ToList()
                .ForEach(url => (firstSet.Contains(url) ||
                                 secondSet.Contains(url)).ShouldBeTrue());
        }
コード例 #27
0
        public void Can_select_ints_using_list_contains()
        {
            var ints = new[] { 1, 20, 30 }.ToList();
            var nullableInts = new int?[] { 5, 30, null, 20 }.ToList();

            using (var db = OpenDbConnection())
            {
                var int10 = new TestType { IntColumn = 10 };
                var int20 = new TestType { IntColumn = 20 };
                var int30 = new TestType { IntColumn = 30 };

                EstablishContext(db, 0, int10, int20, int30);

                var results = db.Select<TestType>(x => ints.Contains(x.IntColumn));
                var resultsNullable = db.Select<TestType>(x => nullableInts.Contains(x.IntColumn));

                CollectionAssert.AreEquivalent(new[] { int20, int30 }, results);
                CollectionAssert.AreEquivalent(new[] { int20, int30 }, resultsNullable);

                Assert.That(db.GetLastSql(), Does.Contain("(@0,@1,@2)").
                                             Or.Contain("(:0,:1,:2)"));
            }
        }
コード例 #28
0
 private bool IsBrowserUnsupported()
 {
     var unsupportedBrowsers = new[] { "opera" };
     var browser = Request.Browser;
     return unsupportedBrowsers.Contains(browser.Browser.ToLower());
 }
コード例 #29
0
	    public void Descendants_Ordered_Properly()
	    {
            var doc = GetNode(1046);

	        var currentLevel = 0;
	        var lastSortOrder = 0;
            var levelChangesAt = new[] { 1046, 1173, 1174 };

            foreach (var d in doc.DescendantsOrSelf())
            {
                if (levelChangesAt.Contains(d.Id))
                {
                    Assert.Greater(d.Level, currentLevel);
                    currentLevel = d.Level;                    
                }
                else
                {
                    Assert.AreEqual(currentLevel, d.Level);
                    Assert.Greater(d.SortOrder, lastSortOrder);                    
                }
                lastSortOrder = d.SortOrder;
            }
	    }
コード例 #30
0
ファイル: Essentials.cs プロジェクト: yashine59fr/PortAIO-1
        /// <summary>
        /// Returns the primary role of a hero.
        /// </summary>
        /// <param name="hero"></param>
        /// <returns></returns>
        public static PrimaryRole GetRole(AIHeroClient hero)
        {
            var assassins = new[] // heroes who use sweepers
            {
                "Ahri", "Akali", "Annie", "Diana", "Ekko", "Elise", "Evelynn", "Fiddlesticks", "Fizz", "Gragas", "Kassadin", "Katarina",
                "Khazix", "Leblanc", "Lissandra", "MasterYi", "Nidalee", "Nocturne", "Rengar", "Shaco",
                "Syndra", "Talon", "Zed", "Kindred"
            };

            var fighters = new[] // heroes who may not upgrade trinket
            {
                "Aatrox", "Darius", "DrMundo", "Fiora", "Gangplank", "Garen", "Gnar", "Hecarim",
                "Illaoi", "Irelia", "Jax", "Jayce", "Kayle", "Kennen", "LeeSin", "Mordekaiser", "Nasus", "Olaf", "Pantheon",
                "RekSai", "Renekton", "Riven", "Rumble", "Shyvana", "Skarner", "Teemo", "Trundle", "Tryndamere", "Udyr", "Vi", "Vladimir",
                "Volibear", "Warwick", "Wukong", "XinZhao", "Yasuo", "Yorick"
            };

            var mages = new[] // mage heroes who may prefer farsight orb
            {
                "Anivia", "AurelionSol", "Azir", "Brand", "Cassiopeia", "Heimerdinger", "Karma",
                "Karthus", "Lux", "Malzahar", "Orianna", "Ryze", "Swain", "Twistedfate",
                "Veigar", "Velkoz", "Viktor", "Xerath", "Ziggs", "Taliyah"
            };

            var supports = new[]
            {
                "Alistar", "Bard", "Blitzcrank", "Braum", "Janna", "Leona", "Lulu", "Morgana", "Nami", "Nunu",
                "Sona", "Soraka", "TahmKench", "Taric", "Thresh",
                "Zilean", "Zyra"
            };

            var tanks = new[]
            {
                "Amumu", "Chogath", "Galio", "JarvanIV", "Malphite", "Maokai", "Nautilus",
                "Poppy", "Rammus", "Sejuani", "Shen", "Singed", "Sion", "Zac"
            };

            var marksmen = new[] // heroes that will 100% buy farsight orb
            {
                "Ashe", "Caitlyn", "Corki", "Draven", "Ezreal", "Graves", "Jhin", "Jinx", "Kalista",
                "KogMaw", "Lucian", "MissFortune", "Quinn", "Sivir", "Tristana", "Twitch", "Urgot", "Varus",
                "Vayne"
            };

            if (assassins.Contains(hero.ChampionName))
            {
                return PrimaryRole.Assassin;
            }

            if (fighters.Contains(hero.ChampionName))
            {
                return PrimaryRole.Fighter;
            }

            if (mages.Contains(hero.ChampionName))
            {
                return PrimaryRole.Mage;
            }

            if (supports.Contains(hero.ChampionName))
            {
                return PrimaryRole.Support;
            }

            if (tanks.Contains(hero.ChampionName))
            {
                return PrimaryRole.Marksman;
            }

            if (marksmen.Contains(hero.ChampionName))
            {
                return PrimaryRole.Marksman;
            }

            return PrimaryRole.Unknown;
        }