public void Adding_Multiple_Types_3() { var items = new List<string> { "Nav1", "Nav2", "Nav3" }; var a = "div".Add( "ul".Add( items.Select(s => new NavRenderable { Text = s }), "Start Nav 2", items.Select(s => new NavRenderable { Text = s }), "span".Add("Start Nav 3"), items.Select(s => new NavRenderable { Text = s }), "Nav over")) .Add("div".Add("After div")); Expect(a.ToString(), Is.EqualTo( "<div>" + "<ul>" + "<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + "Start Nav 2" + "<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + "<span>Start Nav 3</span>" + "<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + "Nav over" + "</ul>" + "<div>After div</div>" + "</div>")); }
public void CollectsAllBindingsAndLoadsThemDistinctOnKernel() { var loadedModules = new List<INinjectModule>(); A.CallTo(() => this.kernel.Load(A<IEnumerable<INinjectModule>>._)) .Invokes((IEnumerable<INinjectModule> modules) => loadedModules.AddRange(modules)); var dependencyA = new DependencyA(); var dependencyB = new DependencyB(); var dependencyDefinitionA = new Dependency<IDependencyA>(bind => bind.ToConstant(dependencyA).InTransientScope()); var dependencyDefinitionB = new Dependency<IDependencyB>(bind => bind.ToConstant(dependencyB).InSingletonScope()); this.testee.Load( new FeatureA( dependencyDefinitionA, dependencyDefinitionB), new FeatureB( dependencyDefinitionA, dependencyDefinitionB), new FeatureC()); loadedModules.Select(_ => _.GetType().Name) .Should().Contain( new[] { typeof(ModuleA), typeof(ModuleB), typeof(ModuleC), typeof(ModuleD) }.Select(_ => _.Name)) .And.BeEquivalentTo(loadedModules.Select(_ => _.GetType().Name).Distinct()); }
public void D_visit_complete_tree_depthFirst_on_VisitDescendants() { // ACT var result = new List<Tuple<List<string>, string>>(); "rootNode".VisitDescendants(this.GetChildNodes, (b, n) => result.Add(Tuple.Create(b.ToList(), n)), depthFirst: true); // ASSERT Assert.AreEqual(5, result.Count()); CollectionAssert.AreEqual(new[] { "leftNode", "leftLeaf", "rightNode", "leftRightLeaf", "rightRightLeaf" }, result.Select(i => i.Item2)); CollectionAssert.AreEqual(new[] { "leftNode", "leftLeaf", "rightNode", "leftRightLeaf", "rightRightLeaf" }, result.Select(i => i.Item2)); CollectionAssert.AreEqual(new[] { "rootNode" }, result.ElementAt(0).Item1); CollectionAssert.AreEqual(new[] { "rootNode", "leftNode" }, result.ElementAt(1).Item1); CollectionAssert.AreEqual(new[] { "rootNode" }, result.ElementAt(2).Item1); CollectionAssert.AreEqual(new[] { "rootNode", "rightNode" }, result.ElementAt(3).Item1); CollectionAssert.AreEqual(new[] { "rootNode", "rightNode" }, result.ElementAt(4).Item1); }
public void CanConvertConcurrently() { var error = false; var threads = new List<ThreadData>(); for (int i = 0; i < 5; i++) { var tmp = new ThreadData() { Thread = new Thread(ThreadStart), WaitHandle = new ManualResetEvent(false) }; threads.Add(tmp); tmp.Thread.Start(tmp); } var handles = threads.Select(x => x.WaitHandle).ToArray(); Assert.IsTrue(WaitHandle.WaitAll(handles, ConcurrentTimeout), "At least one thread timeout"); //WaitAll(handles); threads.ForEach(x => x.Thread.Abort()); var exceptions = threads.Select(x => x.Exception).Where(x => x != null); foreach (var tmp in threads) { if (tmp.Exception != null) { error = true; var tid = tmp.Thread.ManagedThreadId; } } Assert.IsFalse(error, "At least one thread failed!"); }
public void CollectRepoFiles_collects_relative_filenames() { var repoFiles = new List<RepoFile>(); sut.CollectRepoFiles("TestData", repoFiles.Add); var absoluteRepoRoot = Path.Combine(Directory.GetCurrentDirectory(), "TestData"); Assert.That(repoFiles.Select(x => x.RepoRoot).ToArray(), Is.EqualTo( new[] { absoluteRepoRoot, absoluteRepoRoot, absoluteRepoRoot, absoluteRepoRoot, absoluteRepoRoot, absoluteRepoRoot })); Assert.That(repoFiles.Select(x => x.RelativeFileName).ToArray(), Is.EqualTo(new[] { ".sync", "File1.txt", "SubDir1\\File2.txt", "SubDir1\\SubDir1a\\File3.txt", "SubDir1\\SubDir1b\\File4.txt", "SubDir2\\File5.txt" })); }
public void Korrekt_aufgebaute_Datei_wird_eingelesen() { var jobs = new List<Job>(); sut.Jobs_einlesen(jobs.Add); Assert.That(jobs.Select(x => x.Command).ToArray(), Is.EqualTo(new[] { "cmd1", "cmd2", "cmd3" })); Assert.That(jobs.Select(x => x.Parameter1).ToArray(), Is.EqualTo(new[] { null, "p1", "p2" })); Assert.That(jobs.Select(x => x.Parameter2).ToArray(), Is.EqualTo(new[] { null, null, "p3" })); }
public void Can_receive_sequence_of_adds() { var observable = CreateObservable(); var changes = new List<FirkinHashChange<string>>(); observable.Subscribe(changes.Add); observable.Put("foo", 1.ToStream()); observable.Put("bar", 2.ToStream()); observable.Put("baz", 3.ToStream()); Assert.AreEqual(new[] { "foo", "bar", "baz" }, changes.Select(x => x.Key).ToArray()); Assert.AreEqual(new[] { FirkinHashChangeAction.Add, FirkinHashChangeAction.Add, FirkinHashChangeAction.Add }, changes.Select(x => x.Action).ToArray()); }
public void ParseEndUserSuppliedXriIdentifer() { List<char> symbols = new List<char>(XriIdentifier.GlobalContextSymbols); symbols.Add('('); List<string> prefixes = new List<string>(); prefixes.AddRange(symbols.Select(s => s.ToString())); prefixes.AddRange(symbols.Select(s => "xri://" + s.ToString())); foreach (string prefix in prefixes) { var id = Identifier.Parse(prefix + "andrew"); Assert.IsInstanceOfType(typeof(XriIdentifier), id); } }
public void ExtensionDisplayNameShouldBeUsedInBothStandardRoutes() { var blueprint = new ShellBlueprint { Controllers = new[] { new ControllerBlueprint { AreaName ="Long.Name.Foo", Feature =new Feature { Descriptor=new FeatureDescriptor { Extension=new ExtensionDescriptor { Id="Foo", Name="A Foo Module", Path="Foo" } } } }, new ControllerBlueprint { AreaName ="Long.Name.Bar", Feature =new Feature { Descriptor=new FeatureDescriptor { Extension=new ExtensionDescriptor { Id="Bar", Name="Bar", Path="BarBar" } } } } } }; var routeProvider = new StandardExtensionRouteProvider(blueprint); var routes = new List<RouteDescriptor>(); routeProvider.GetRoutes(routes); Assert.That(routes, Has.Count.EqualTo(4)); var fooAdmin = routes.Select(x => x.Route).OfType<Route>() .Single(x => x.Url == "Admin/Foo/{action}/{id}"); var fooRoute = routes.Select(x => x.Route).OfType<Route>() .Single(x => x.Url == "Foo/{controller}/{action}/{id}"); var barAdmin = routes.Select(x => x.Route).OfType<Route>() .Single(x => x.Url == "Admin/BarBar/{action}/{id}"); var barRoute = routes.Select(x => x.Route).OfType<Route>() .Single(x => x.Url == "BarBar/{controller}/{action}/{id}"); Assert.That(fooAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Foo")); Assert.That(fooRoute.DataTokens["area"], Is.EqualTo("Long.Name.Foo")); Assert.That(barAdmin.DataTokens["area"], Is.EqualTo("Long.Name.Bar")); Assert.That(barRoute.DataTokens["area"], Is.EqualTo("Long.Name.Bar")); }
public void Adding_Multiple_NavRenderables() { var items = new List<string> { "Nav1", "Nav2", "Nav3" }; var a = "ul".Add( items.Select(s => new NavRenderable { Text = s }), items.Select(s => new NavRenderable { Text = s }), items.Select(s => new NavRenderable { Text = s })); Expect(a.ToString(), Is.EqualTo( "<ul>" + @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + @"<li>Nav1</li><li>Nav2</li><li>Nav3</li>" + "</ul>")); }
public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping() { var listOfCalls = new List<BindMappingEventArgs>(); var configuration = new Configuration(); configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>()); configuration.AfterBindMapping += (sender, args) => { Assert.That(sender, Is.SameAs(configuration)); listOfCalls.Add(args); }; configuration.AddXmlString(ProductLineMapping); configuration.AddXmlString(ModelMapping); Assert.That(listOfCalls.Count, Is.EqualTo(2)); Assert.That(listOfCalls.Select(x => x.FileName).All(x => x != null), Is.True); Assert.That(listOfCalls.Select(x => x.Mapping).All(x => x != null), Is.True); Assert.That(listOfCalls.Select(x => x.Dialect).All(x => x.GetType() == typeof(MsSql2008Dialect)), Is.True); }
public void WhenSubscribedToAfterBindThenRaiseEventForEachMapping() { var listOfCalls = new List<BindMappingEventArgs>(); var configuration = new Configuration(); configuration.DataBaseIntegration(x => x.Dialect<MsSql2008Dialect>()); configuration.AfterBindMapping += (sender, args) => { sender.Should().Be.SameInstanceAs(configuration); listOfCalls.Add(args); }; configuration.AddXmlString(ProductLineMapping); configuration.AddXmlString(ModelMapping); listOfCalls.Count.Should().Be(2); listOfCalls.Select(x => x.FileName).All(x => x.Satisfy(filename => filename != null)); listOfCalls.Select(x => x.Mapping).All(x => x.Satisfy(mappingDoc => mappingDoc != null)); listOfCalls.Select(x => x.Dialect).All(x => x.Satisfy(dialect => dialect.GetType() == typeof(MsSql2008Dialect))); }
public void TestReadPersonWithMultiplePendingModificationsActivated() { // Make a separate copy from the main tree used in other tests var tempTree = new FamilySearchFamilyTree(true); var features = new List<Feature>(); tempTree.AuthenticateViaOAuth2Password(Resources.TestUserName, Resources.TestPassword, Resources.TestClientId); // Get all the features that are pending IRestRequest request = new RedirectableRestRequest() .Accept(MediaTypes.APPLICATION_JSON_TYPE) .Build("https://sandbox.familysearch.org/platform/pending-modifications", Method.GET); IRestResponse response = tempTree.Client.Handle(request); // Get each pending feature features.AddRange(response.ToIRestResponse<FamilySearchPlatform>().Data.Features); // Add every pending feature to the tree's current client tempTree.Client.AddFilter(new ExperimentsFilter(features.Select(x => x.Name).ToArray())); var state = tempTree.AddPerson(TestBacking.GetCreateMalePerson()); cleanup.Add(state); // Ensure a response came back Assert.IsNotNull(state); var requestedFeatures = String.Join(",", state.Request.GetHeaders().Get("X-FS-Feature-Tag").Select(x => x.Value.ToString())); // Ensure each requested feature was found in the request headers Assert.IsTrue(features.TrueForAll(x => requestedFeatures.Contains(x.Name))); }
public void MessageReceivedEvent() { ICollection<RawMessage> expectedOutput = new List<RawMessage>(); expectedOutput.Add(new RawMessage("THEGAME", "a", "b", "cd ef g")); string input = string.Join("\r\n", expectedOutput.Select((message) => message.ToString()).ToArray()) + "\r\n"; IEnumerator<RawMessage> messageChecker = expectedOutput.GetEnumerator(); var writer = new IO.Helpers.DummyRawMessageWriter(); using(var stringReader = new StringReader(input)) using(var reader = new RawMessageTextReader(stringReader)) { using(var client = new Ondit.Client.Client(reader, writer)) { client.RawMessageReceived += delegate(object sender, RawMessageEventArgs e) { bool elementExists = messageChecker.MoveNext(); Assert.IsTrue(elementExists); Assert.AreEqual(messageChecker.Current, e.Message); }; foreach(var expectedMessage in expectedOutput) { client.HandleMessage(); } } } }
public static void Succeed(params Action[] assertions) { var errors = new List<Exception>(); foreach (var assertion in assertions) try { assertion(); } catch (Exception ex) { errors.Add(ex); } if (errors.Any()) { var ex = new AssertionException( string.Join(Environment.NewLine, errors.Select(e => e.Message)), errors.First()); // Use stack trace from the first exception to ensure first failed Assert is one click away ReplaceStackTrace(ex, errors.First().StackTrace); throw ex; } }
private static string GetSearchResult(List<Package> packages) { Uri uri = new Uri(BaseUrl); string baseUri = uri.Scheme + "://" + uri.Host + ":" + uri.Port; string apiUri = baseUri + "/api/v2/"; DateTime updated = packages.Any() ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated : DateTime.UtcNow; SeachFeed.feed feed = new SeachFeed.feed { @base = apiUri, count = packages.Count, updated = updated, link = new SeachFeed.feedLink(apiUri + "Packages"), entry = packages.Select(p => Search.GetPackageEntry(p, uri)).ToArray() }; XmlSerializer serializer = new XmlSerializer(typeof(SeachFeed.feed)); MemoryStream ms = new MemoryStream(); serializer.Serialize(ms, feed); ms.Position = 0; return new StreamReader(ms).ReadToEnd(); }
public void ReadParse_Handles_Complete_Frames_In_Different_Buffers() { var config = new Configuration { BufferPool = new RecyclableMemoryStreamManager() }; var connectionMock = new Mock<Connection>(MockBehavior.Loose, (byte)2, Address, config); var streamIds = new List<short>(); var responses = new List<Response>(); connectionMock.Setup(c => c.RemoveFromPending(It.IsAny<short>())) .Callback<short>(id => streamIds.Add(id)) .Returns(() => new OperationState((ex, r) => responses.Add(r))); var connection = connectionMock.Object; var buffer = GetResultBuffer(127); connection.ReadParse(buffer, buffer.Length); CollectionAssert.AreEqual(new short[] { 127 }, streamIds); buffer = GetResultBuffer(126); connection.ReadParse(buffer, buffer.Length); CollectionAssert.AreEqual(new short[] { 127, 126 }, streamIds); buffer = GetResultBuffer(125); connection.ReadParse(buffer, buffer.Length); CollectionAssert.AreEqual(new short[] { 127, 126, 125 }, streamIds); TestHelper.WaitUntil(() => responses.Count == 3); Assert.AreEqual(3, responses.Count); CollectionAssert.AreEqual(Enumerable.Repeat(ResultResponse.ResultResponseKind.Void, 3), responses.Select(r => ((ResultResponse) r).Kind)); }
public void Poll_client_pulls_from_sqs_and_calls_callback() { var mockSqsClient = new MockSqsClient(); mockSqsClient.FillQueue(15); var pollster = new SqsPollClient(mockSqsClient, TaskTimerFactory.Current); Assert.AreEqual(15, mockSqsClient.Queued.Count, "queue was accessed prematurely"); var posted = new List<AwsSqsMessage>(); pollster.Listen("foo", 300.Seconds(), posted.Add); Assert.IsTrue(Wait.For(() => mockSqsClient.Queued.Count == 0, 10.Seconds()), "queue did not get depleted in time"); Assert.IsTrue( Wait.For(() => mockSqsClient.ReceiveCalled == 3, 5.Seconds()), string.Format("receive called the wrong number of times: {0} != {1}", 3, mockSqsClient.ReceiveCalled) ); Assert.AreEqual(15, mockSqsClient.Delivered.Count, "delivered has the wrong number of messages"); Assert.AreEqual( mockSqsClient.Delivered.Select(x => x.MessageId).ToArray(), mockSqsClient.Deleted.Select(x => x.MessageId).ToArray(), "delivered and deleted don't match" ); Assert.AreEqual( mockSqsClient.Delivered.Select(x => x.MessageId).ToArray(), posted.Select(x => x.MessageId).ToArray(), "delivered and posted don't match" ); }
private List<PropertyInfo> SelectProperties(Type t) { IPropertySelectorPolicy selector = new PropertySelectorPolicy<DependencyAttribute>(); IBuilderContext context = GetContext(t); var properties = new List<SelectedProperty>(selector.SelectProperties(context, context.PersistentPolicies)); return properties.Select(sp => sp.Property).ToList(); }
public void CalculateQuestionDistribution() { var notBodyQuestions = new List<long>(); var bodyDict = body.ToDictionary(); foreach (var question in questions.GetAllQuestions()) { var text = question.Title + " " + question.Text; var words = Regex.Split(text, @"\W+"); var bodyWords = words.Where(bodyDict.ContainsKey).Distinct().ToList(); if (!bodyWords.Any()) { notBodyQuestions.Add(question.Id); } foreach (var word in bodyWords) { bodyDict[word].Inc(question.Id); } } Console.WriteLine((0.0 + notBodyQuestions.Count) / questions.GetAllQuestions().Count()); File.WriteAllText("NotBody.txt", String.Join("\n\n", notBodyQuestions.Select(id => { var q = questions.GetQuestion(id); return q.Title + "\n" + q.Text; }))); }
public void ConvertingShortResultsInSameValueAsUShort() { var indices = new List<int> { 4593, 41593, 3954593 }; var shorts = indices.Select(index => (short)(index+1)).ToList(); for (int num = 0; num < indices.Count; num++) Assert.AreEqual((ushort)indices[num]+1, (ushort)shorts[num]); }
public void AddExistingUsersToRoles() { tests = UserManagementTests.Update(); var users = new List<User> { new User { Username = "******", Email = "*****@*****.**", Password = "******" }, new User { Username = "******", Email = "*****@*****.**", Password = "******" }, }; foreach (var user in users) { this.tests.Storage.CreateUser(user); } var usernames = users.Select(u => u.Username); var roles = new List<Role> { Role.Teacher }; this.tests.Storage.AddUsersToRoles(usernames, roles); foreach (var user in users) { Assert.IsTrue(this.tests.Storage.GetUserRoles(user.Username).Contains(roles.Single())); } this.tests.Storage.RemoveUsersFromRoles(usernames, roles); foreach (var user in users) { this.tests.Storage.DeleteUser(u => u.Username == user.Username); } }
public void GetNextChallengeBoardCategory() { var repository = new TestRepository(); // create a game with some challenges var board = new Board(); repository.Add(board); var game = new Game() { BoardId = board.Id }; repository.Add(game); var category = new ChallengeCategory(); repository.Add(category); var challenge1 = new Challenge() { ChallengeCategoryId = category.Id }; var challenge2 = new Challenge() { ChallengeCategoryId = category.Id }; var challenge3 = new Challenge() { ChallengeCategoryId = category.Id }; var challenges = new Challenge[] { challenge1, challenge2, challenge3 }; repository.AddAll(challenges); repository.Add(new BoardChallengeCategory() { BoardId = board.Id, ChallengeCategoryId = category.Id }); // keep getting the next challenge until all challenges should have been used var usedChallenges = new List<Challenge>(); foreach (Challenge challenge in challenges) { usedChallenges.Add(game.GetNextChallenge(0)); } // verify that all challenges were used CollectionAssert.AreEqual(challenges.Select(x => x.Id).OrderBy(x => x), usedChallenges.Select(x => x.Id).OrderBy(x => x)); // verify that more challenges can be retrieved Assert.IsNotNull(game.GetNextChallenge(0)); }
private static string GetFindPackageResult(string url, List<Package> packages, bool latestVersion) { string apiUri = url.Replace("&", "&"); Uri uri = new Uri(apiUri); DateTime updated = packages.Any() ? packages.OrderByDescending(p => p.DateUpdated).First().DateUpdated : DateTime.UtcNow; entry[] entries = latestVersion ? new[] { PackageDetails.GetPackageEntry(packages.FirstOrDefault(p => p.LatestVersion), uri) } : packages.Select(p => PackageDetails.GetPackageEntry(p, uri)).ToArray(); feed feed = new feed { @base = InvokeUrl + "/", id = WebUtility.HtmlDecode(uri.ToString()), title = new feedTitle("FindPackagesById"), updated = updated, link = new feedLink("FindPackagesById", "FindPackagesById"), entry = entries }; XmlSerializer serializer = new XmlSerializer(typeof(feed)); MemoryStream ms = new MemoryStream(); serializer.Serialize(ms, feed); ms.Position = 0; return new StreamReader(ms).ReadToEnd(); }
public void Type_changing() { IList<Product> products = new List<Product>(); products .Select(p => p.Manufacturer); }
public void ShouldShowForumListOnLoadWithData() { var view = _repository.DynamicMock<IForumListView>(); var provider = _repository.DynamicMock<IForumProvider>(); var loader = default(IEventRaiser); var data = new List<Core.Models.Forum> {new Core.Models.Forum {Name = "First Feature Forum"}}; var display = data.Select(forum => new ForumMapper().ToDisplay(forum)).ToList(); With.Mocks(_repository). ExpectingInSameOrder(() => { view.Load += null; loader = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(view.IsPostBack).Return(false); Expect.Call(provider.List()).Return(data); Expect.Call(view.Forums = display).IgnoreArguments(); Expect.Call(view.DataBind); SetupResult.For(view.Forums).Return(display); }). Verify(() => { new ForumListPresenter(view, provider); loader.Raise(null, new EventArgs()); Assert.IsNotNull(view.Forums); Assert.AreEqual(data.Count, view.Forums.ToList().Count); }); }
public void AllValuesInArrayAreIndexed() { var coll = GetCollection(); // Make sure property Tags is indexed coll.Indices.EnsureIndex("Tags"); // Insert something where Tags is list of values const string key = "a key of some sort"; var values = new HashSet<object> {"A", "B", DateTime.Now, null, Math.PI}; coll.Update(key, new {Tags = values}); // Now, extract what the index really contains var indexContent = new List<KeyValuePair<IndexValue, string>>(); coll.Indices.VisitIndex("Tags", indexContent.Add); // First of all, each index entry must point to our key foreach (var kv in indexContent) { Assert.AreEqual(key, kv.Value); } // Second, the index should contain the array values var indexValues = new HashSet<object>(indexContent.Select(kv => kv.Key.Value)); Assert.AreEqual(0, indexValues.Except(values).Count(), "Index values are too many"); Assert.AreEqual(0, values.Except(indexValues).Count(), "Index values are too feew"); }
public void PerThreadTest(int numberOfThreads) { IoCContainer.Register<ILogger, Logger>(new PerThread()); var tasks = new List<Task<string>>(); for (int i = 0; i < numberOfThreads; i++) { var task = Task<string>.Factory.StartNew(() => { var logger1 = IoCContainer.Resolve<ILogger>(); var result1 = logger1.Name; IoCContainer.Release(logger1); var logger2 = IoCContainer.Resolve<ILogger>(); var result2 = logger2.Name; IoCContainer.Release(logger1); Assert.AreEqual(result1, result2); return result1; }); tasks.Add(task); } var results = tasks.Select(t => t.Result).ToList(); results.ForEach(Console.WriteLine); var duplicates = results.GroupBy(i => i).Where(g => g.Count() > 1).Select(g => g.Key); Assert.That(!duplicates.Any()); }
public void AddExistingUsersToRoles() { var users = new List<User> { new User {Username = "******", Email = "*****@*****.**", Password = "******"}, new User {Username = "******", Email = "*****@*****.**",Password = "******"}, }; _Tests.MockStorage.Setup(s => s.GetCurrentUser()).Returns(_Tests.Storage.GetUser(u => u.Username == "panza")); foreach (var user in users) { _Tests.Storage.CreateUser(user); } var usernames = users.Select(u => u.Username); var roles = new List<Role> {Role.Teacher}; _Tests.Storage.AddUsersToRoles(usernames, roles); foreach (var user in users) { Assert.IsTrue(_Tests.Storage.GetUserRoles(user.Username).Contains(roles.Single())); } _Tests.Storage.RemoveUsersFromRoles(usernames, roles); foreach (var user in users) { _Tests.Storage.DeleteUser(u => u.Username == user.Username); } }
public void TestGetOnlineGivingProgramsForProgramType() { var programs = new List<Program> { new Program { CommunicationTemplateId = 1, Name = "Program 1", ProgramId = 2, ProgramType = 3 }, new Program { CommunicationTemplateId = 4, Name = "Program 2", ProgramId = 5, ProgramType = 6 }, }; _mpProgramService.Setup(mocked => mocked.GetOnlineGivingPrograms(3)).Returns(programs); var result = _fixture.GetOnlineGivingPrograms(3); _mpProgramService.VerifyAll(); Assert.IsNotNull(result); Assert.AreEqual(2, result.Count); var expectedResult = programs.Select(Mapper.Map<ProgramDTO>).ToList(); for(var i = 0; i < 2; i++) { Assert.AreEqual(expectedResult[i].ProgramType, result[i].ProgramType); Assert.AreEqual(expectedResult[i].CommunicationTemplateId, result[i].CommunicationTemplateId); Assert.AreEqual(expectedResult[i].Name, result[i].Name); Assert.AreEqual(expectedResult[i].ProgramId, result[i].ProgramId); } }