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 Given_selected_responsibilities_When_GetViewModel_Then_those_responsibilities_are_marked_as_selected()
        {
            // Given
            const int companyId = 12345;
            var templates = new List<StatutoryResponsibilityTemplateDto>
                            {
                                new StatutoryResponsibilityTemplateDto() { Id = 123L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"}},
                                new StatutoryResponsibilityTemplateDto() { Id = 456L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"} },
                                new StatutoryResponsibilityTemplateDto() { Id = 789L, Description = "description", ResponsibilityCategory = new ResponsibilityCategoryDto() { Category = "category"}, ResponsibilityReason = new ResponsibilityReasonDto() { Reason = "reason"} }
                            };

            _statutoryResponsibilityTemplateService
               .Setup(x => x.GetStatutoryResponsibilityTemplates())
               .Returns(templates);

            // When
            var result = GetTarget()
                .WithCompanyId(companyId)
                .WithSelectedResponsibilityTemplates(new [] { templates.First().Id })
                .GetViewModel();

            // Then
            Assert.IsTrue(result.Responsibilities.Single(x => x.Id == templates.First().Id ).IsSelected);
            Assert.IsFalse(result.Responsibilities.Single(x => x.Id == templates.ElementAt(1).Id ).IsSelected);
            Assert.IsFalse(result.Responsibilities.Single(x => x.Id == templates.ElementAt(2).Id).IsSelected);
        }
 public void ForEachGroupWithActionTest()
 {
     var numbers = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
     var executedGroups = new List<IEnumerable<int>>();
     numbers.ForEachGroup(9, executedGroups.Add);
     Assert.AreEqual(2, executedGroups.Count);
     Assert.AreEqual(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, executedGroups.ElementAt(0));
     Assert.AreEqual(new[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }, executedGroups.ElementAt(1));
 }
Ejemplo n.º 4
0
        public void TestFibSeq(int value)
        {
            var result = utility.getFibonacciSequence(5);
            List<int> numbers = new List<int>();
            int a = 0;
            int b = 1;

            if (value > 0)
            {
                int c = a;
                for (int i = 0; c <= value; i++)
                {
                    c = a;
                    a = b;
                    b = b + c;

                    if (c <= value)
                        numbers.Add(c);
                }
            }
            else
            {
                numbers.Add(value);
            }

            if (numbers.ElementAt(numbers.Count - 1) != value)
                numbers.Add(value);

            Assert.That(result, Is.EqualTo(numbers));
        }
Ejemplo n.º 5
0
        public void HandleMatchesForPlayerQuery_ShouldReturnMatchesPlayerWasMemberOf()
        {
            // Arrange
            var random = new Random();
            var nzl = setUpHelper.SetUpCountry("New Zealand");
            var aus = setUpHelper.SetUpCountry("Australia");

            setUpHelper.PopulateCountryPlayerPool(nzl.Name);
            setUpHelper.PopulateCountryPlayerPool(aus.Name);

            var matches = new List<Match>();

            for (var i = 0; i < 5 +random.Next(4); i++)
            {
                var matchID = setUpHelper.SetUpMatch(nzl, aus);
                var match = Resolve<IRepository<Match>>().GetById(matchID);
                matches.Add(match);
            }

            var randomMatch = matches.ElementAt(random.Next(matches.Count - 1));
            var selectedPlayerIndex = random.Next(randomMatch.Team1.Members.Count() - 1);
            var selectedPlayer = randomMatch.Team1.Members.ElementAt(selectedPlayerIndex);

            var expectedResult = matches.Where(m => m.Teams.Any(t => t.Members.Contains(selectedPlayer))).ToArray();

            // Act
            var result = queryHandler.Handle(new MatchesForPlayerQuery(selectedPlayer.Id));

            // Assert
            result.Should().BeEquivalentTo(expectedResult);
            result.First().Team1.Members.Should().BeEquivalentTo(expectedResult.First().Team1.Members);
        }
Ejemplo n.º 6
0
 public void OriginalThing_DoesThing()
 {
     var strings = new List<string>();
     new OriginalThing().DoesThing(strings);
     strings.Should().NotBeEmpty();
     strings.Should().HaveCount(1);
     strings.ElementAt(0).Should().Contain("Original");
 }
Ejemplo n.º 7
0
 public void PruebaDListaCargos()
 {
     List<Cargo> listaCargo = new List<Cargo>();
     Core.LogicaNegocio.Comandos.ComandoCargo.ConsultarTabla comandoConsultar =
                                             FabricaComandoCargo.CrearComandoConsultarTabla();
     listaCargo = comandoConsultar.Ejecutar();
     Assert.AreEqual(listaCargo.ElementAt(listaCargo.Count - 1).Nombre, "Probador BD");
 }
Ejemplo n.º 8
0
 public void ProvidedOriginalThing_DoesThing()
 {
     var strings = new List<string>();
     var thingServer = new Mock<IThingFactory>();
     thingServer.Setup(ts => ts.GetThing()).Returns(new OriginalThing());
     thingServer.Object.GetThing().DoesThing(strings);
     strings.Should().NotBeEmpty();
     strings.Should().HaveCount(1);
     strings.ElementAt(0).Should().Contain("Original");
 }
Ejemplo n.º 9
0
 public static void Test_RemapRange()
 {
     List<double> input = new List<double> { 0, 1, 2, 3, 4 };
     List<double> expectedResults = new List<double> { -10, -2.5, 5, 12.5, 20 };
     List<double> results = (List<double>)DSCore.Math.RemapRange(input, -10, 20);
     for(int i = 0; i < expectedResults.Count; i++)
     {
         Assert.AreEqual(expectedResults.ElementAt(i), results.ElementAt(i));
     }
 }
Ejemplo n.º 10
0
        public async void AddImageWithRealContextTest()
        {

            var count = 5;
            var contexts = new List<ShopContext>();
            for (int i = 0; i < count; i++)
            {
                contexts.Add(new ShopContext());
            }
            var uof = new List<UnitOfWorkStore>();
            for (int i = 0; i < count; i++)
            {
                uof.Add(new UnitOfWorkStore(contexts.ElementAt(i)));
            }
            var repo = new List<ImageRepository>();
            for (int i = 0; i < count; i++)
            {
                repo.Add(new ImageRepository(contexts.ElementAt(i)));
            }
            var imgSvc = new List<ImageService>();
            for (int i = 0; i < count; i++)
            {
                imgSvc.Add(new ImageService(uof.ElementAt(i), repo.ElementAt(i)));
            }
            var ctrls = new List<PhotoController>();
            for (int i = 0; i < count; i++)
            {
                ctrls.Add(new PhotoController(uof.ElementAt(i), imgSvc.ElementAt(i), _log.Object)
                {
                    Request = new HttpRequestMessage()
                });
            }
            for (int i = 0; i < count; i++)
            {
                await ctrls.ElementAt(i).AddPhoto(521,new FileData()
                {
                    FileName = "test"+i,
                });
            }
        }
Ejemplo n.º 11
0
        public void SimpleExample()
        {
            // This is the result we want to return when execute reader is executed
            var fakeDataReader = new FakeDataReader(0,"UserId","Name");
            fakeDataReader.AddRow(1, "Smith");
            fakeDataReader.AddRow(2, "John");

            var result = new List<User>();
            using (var connection = new FakeDbConnection("ConnectionString", dbCommand => fakeDataReader))
            {
                connection.Open();
                using (IDbCommand command = connection.CreateCommand())
                {
                    command.CommandText = "SELECT * FROM Users";

                    IDbDataParameter dbDataParameter = command.CreateParameter();
                    dbDataParameter.ParameterName = "ParameterName";
                    dbDataParameter.DbType = DbType.Int32;
                    dbDataParameter.Value = 0;

                    command.Parameters.Add(dbDataParameter);
                    using (IDataReader reader = command.ExecuteReader())
                    {

                        while (reader.Read())
                        {
                            result.Add(new User { UserId = reader.GetInt32(0), Name = reader.GetString(1)});
                        }
                    }
                }
            }

            Assert.That(result.Count, Is.EqualTo(2));

            Assert.That(result.ElementAt(0).UserId, Is.EqualTo(1));
            Assert.That(result.ElementAt(0).Name, Is.EqualTo("Smith"));

            Assert.That(result.ElementAt(1).UserId, Is.EqualTo(2));
            Assert.That(result.ElementAt(1).Name, Is.EqualTo("John"));
        }
Ejemplo n.º 12
0
        public void ProvidedOriginalThing_DoesThing()
        {
            var strings = new List<string>();
            var factory = new OriginalThingFactory();
            var originalThing = factory.GetThing();

            originalThing.Should().BeOfType<OriginalThing>();

            originalThing.DoesThing(strings);
            strings.Should().NotBeEmpty();
            strings.Should().HaveCount(1);
            strings.ElementAt(0).Should().Contain("Original");
        }
        public void should_be_sortable()
        {
            const string kingsCross = "Kings Cross";
            const string bank = "Bank";
            const string princeRegent = "Prince Regent";
            const short fare = 10;

            var accountId = Guid.NewGuid();

            var jny1 = new Journey(accountId, kingsCross, bank);
            var jny2 = new Journey(accountId, bank, princeRegent);
            var jny3 = new Journey(accountId, princeRegent, bank);

            jny1.AssignFare((o, d) => fare);
            jny2.AssignFare((o, d) => fare);
            jny3.AssignFare((o, d) => fare);

            var jourenys = new List<Journey>(new[] {jny2, jny3, jny1});
            jourenys.Sort();

            Assert.That(jourenys.First().Export().Origin, Is.EqualTo(kingsCross));
            Assert.That(jourenys.First().Export().Destination, Is.EqualTo(bank));
            Assert.That(jourenys.First().Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.First().Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.First().Export().JourneyId, Is.Not.EqualTo(Guid.Empty));

            Assert.That(jourenys.ElementAt(1).Export().Origin, Is.EqualTo(bank));
            Assert.That(jourenys.ElementAt(1).Export().Destination, Is.EqualTo(princeRegent));
            Assert.That(jourenys.ElementAt(1).Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.ElementAt(1).Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.ElementAt(1).Export().JourneyId, Is.Not.EqualTo(Guid.Empty));

            Assert.That(jourenys.Last().Export().Origin, Is.EqualTo(princeRegent));
            Assert.That(jourenys.Last().Export().Destination, Is.EqualTo(bank));
            Assert.That(jourenys.Last().Export().Fare, Is.EqualTo(10));
            Assert.That(jourenys.Last().Export().AccountId, Is.EqualTo(accountId));
            Assert.That(jourenys.Last().Export().JourneyId, Is.Not.EqualTo(Guid.Empty));
        }
Ejemplo n.º 14
0
        public void ProvidedFakeThing_DoesThing()
        {
            var strings = new List<string>();
            var factory = new FakeThingFactory();
            var fakeThing = factory.GetThing();

            fakeThing.Should().BeOfType<FakeThing>();

            fakeThing.DoesThing(strings);

            strings.Should().NotBeEmpty();
            strings.Should().HaveCount(1);
            strings.ElementAt(0).Should().Contain("Fake");
        }
Ejemplo n.º 15
0
        public void CompositeIndicator()
        {
            var ciResults = new List<DataPoint<decimal>>();
            var maResults = new List<DataPoint<decimal>>();

            var ci = new CountIndicator(TimeSpan.FromSeconds(1));
            var ma = new MovingAverageIndicator(2);
            
            // composite indicator
            ci.Subscribe(ma);
            ci.Subscribe(ciResults.Add);
            ma.Subscribe(maResults.Add);

            // 2 second test

            // produce 10 in the second #1
            for (int i = 0; i < 10; i++)
            {
                ci.OnNext(new DataPoint<decimal>(DateTime.Now, 1));
                Thread.Sleep(99);
            }
            Thread.Sleep(50);
            // produce 20 in the second #2
            for (int i = 0; i < 20; i++)
            {
                ci.OnNext(new DataPoint<decimal>(DateTime.Now, 1));
                Thread.Sleep(48);
            }


            Thread.Sleep(50);

            Assert.That(ciResults.ElementAt(0).Value, Is.EqualTo(10));
            Assert.That(ciResults.ElementAt(1).Value, Is.EqualTo(20));
            Assert.That(maResults.ElementAt(0).Value, Is.EqualTo(15));

        }
Ejemplo n.º 16
0
        public void TestEvenSeq(int value)
        {
            var result = utility.getEvenSequence(5);
            List<int> numbers = new List<int>();
            for (int i = 1; i <= value; i++)
            {
                if ((i % 2) == 0)
                {
                    numbers.Add(i);
                }
            }

            if (numbers.ElementAt(numbers.Count - 1) != value)
                numbers.Add(value);

            Assert.That(result, Is.EqualTo(numbers));
        }
Ejemplo n.º 17
0
        public void testDualFuncPipeNormal()
        {

            var _Strings = new List<String>() { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
            var _Numbers = Enumerable.Range(1, 10);
            var _Pipe    = new FuncPipe<String, Int32, String>((A, B) => A + "-" + B);
            _Pipe.SetSourceCollection1(_Strings);
            _Pipe.SetSourceCollection2(_Numbers);

            var _Counter = 0;
            while (_Pipe.MoveNext())
            {
                Assert.AreEqual(_Pipe.Current, _Strings.ElementAt(_Counter) + "-" + _Numbers.ElementAt(_Counter));
                _Counter++;
            }

            Assert.AreEqual(_Counter, 10);

        }
Ejemplo n.º 18
0
		public void DataMigration7000029Test()
		{
			//Bring in data from xml file.
			var dtos = DataMigrationTestServices.ParseProjectFile("DataMigration7000029Tests.xml");

			//Now create all the Mock classes for the classes in my test data.
			//eg LangProject base class is CmProject which has a base class of CmObject
			//eg LexEntry base class is CmObject
			var mockMDC = new MockMDCForDataMigration();
			mockMDC.AddClass(1, "CmObject", null, new List<string>
													{
														"CmProject",
														"CmMajorObject",
														"LexEntry",
														"LexSense",
														"CmPicture",
														"CmFolder",
														"CmFile"
													});
			mockMDC.AddClass(2, "CmProject", "CmObject", new List<string> { "LangProject" });
			mockMDC.AddClass(3, "LangProject", "CmProject", new List<string>());

			mockMDC.AddClass(4, "CmMajorObject", "CmObject", new List<string> { "LexDb" });
			mockMDC.AddClass(5, "LexDb", "CmMajorObject", new List<string>());

			mockMDC.AddClass(6, "LexEntry", "CmObject", new List<string>());
			mockMDC.AddClass(7, "LexSense", "CmObject", new List<string>());
			mockMDC.AddClass(8, "CmPicture", "CmObject", new List<string>());
			mockMDC.AddClass(9, "CmFolder", "CmObject", new List<string>());
			mockMDC.AddClass(10, "CmFile", "CmObject", new List<string>());
			//-------------------+++++++++++++++++++++++++=

			IDomainObjectDTORepository dtoRepos = new DomainObjectDtoRepository(7000028, dtos, mockMDC, @"C:\FwWW\DistFiles\Projects\Sena 3", FwDirectoryFinder.FdoDirectories);

			//Get the Element <rt guid="b8bdad3d-9006-46f0-83e8-ae1d1726f2ad" class="LangProject">
			var langProjDto = dtoRepos.AllInstancesSansSubclasses("LangProject").First();

			var langProjElement = XElement.Parse(langProjDto.Xml);
			var langProjLinkedFilesRootDir = langProjElement.XPathSelectElement("LinkedFilesRootDir");
			Assert.That(langProjLinkedFilesRootDir, Is.Not.Null, "Before the migration we should have a 'LinkedFilesRootDir' element on LangProj");
			var langProjPictures = langProjElement.XPathSelectElement("Pictures");
			Assert.That(langProjPictures, Is.Not.Null, "Before the migration we should have a 'Pictures' element on LangProj");
			var langProjMedia = langProjElement.XPathSelectElement("Media");
			Assert.That(langProjMedia, Is.Not.Null, "Before the migration we should have a 'Media' element on LangProj");

			//Get the Elements  for class="CmFile"
			var CmFileDtosBeforeMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");
			//Get all the file paths (as strings) for the CmFile's in the project
			var filesPathsBeforeMigration = new List<String>();
			foreach (var fileDto in CmFileDtosBeforeMigration)
			{
				filesPathsBeforeMigration.Add(GetCmFilePath(fileDto));
			}
			Assert.That(filesPathsBeforeMigration.ElementAt(0), Is.EqualTo(@"Pictures\Jude1.jpg"));
			Assert.That(filesPathsBeforeMigration.ElementAt(1), Is.EqualTo(@"Pictures\Rick USVI-extraOne.jpg"));
			Assert.That(filesPathsBeforeMigration.ElementAt(2), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\RickKayak.jpg"));
			Assert.That(filesPathsBeforeMigration.ElementAt(3), Is.EqualTo(@"C:\FwWW\DistFiles\RickKayak.jpg"));
			Assert.That(filesPathsBeforeMigration.ElementAt(4), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\Pictures\Rick USVI.jpg"));
			Assert.That(filesPathsBeforeMigration.ElementAt(5), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
			Assert.That(filesPathsBeforeMigration.ElementAt(6), Is.EqualTo(@"C:\FwWW\DistFiles\Projects\Sena 3\LinkedFiles\AudioVisual\MacLeanKidsMovie.WMV"));
			Assert.That(filesPathsBeforeMigration.ElementAt(7), Is.EqualTo(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV"));

			//=====================================================================================================
			//Do Migration
			m_dataMigrationManager.PerformMigration(dtoRepos, 7000029, new DummyProgressDlg());
			//=====================================================================================================

			//make sure the version was updated.
			Assert.AreEqual(7000029, dtoRepos.CurrentModelVersion, "Wrong updated version.");

			//Now check that all the CmFile's have paths which are correct.
			//Get the Elements  for class="CmFile"
			var CmFileDtosAfterMigration = dtoRepos.AllInstancesSansSubclasses("CmFile");
			//Get all the file paths (as strings) for the CmFile's in the project
			var filesPathsAfterMigration = new List<String>();
			foreach (var fileDto in CmFileDtosAfterMigration)
			{
				filesPathsAfterMigration.Add(GetCmFilePath(fileDto));
			}
			//Now check to ensure path are corrected relative to LinkedFiles
			//Also ensure ones that are not relative to the LinkedFiles path are not changed.
			Assert.That(filesPathsAfterMigration.ElementAt(0), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Jude1.jpg")));
			Assert.That(filesPathsAfterMigration.ElementAt(1), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Rick USVI-extraOne.jpg")));
			Assert.That(filesPathsAfterMigration.ElementAt(2), Is.EqualTo(FileUtils.ChangePathToPlatform(@"RickKayak.jpg")));
			Assert.That(filesPathsAfterMigration.ElementAt(3), Is.EqualTo(FileUtils.ChangePathToPlatform(@"C:\FwWW\DistFiles\RickKayak.jpg")));
			Assert.That(filesPathsAfterMigration.ElementAt(4), Is.EqualTo(FileUtils.ChangePathToPlatform(@"Pictures\Rick USVI.jpg")));
			Assert.That(filesPathsAfterMigration.ElementAt(5), Is.EqualTo(FileUtils.ChangePathToPlatform(@"AudioVisual\Untitled5.WMV")));
			Assert.That(filesPathsAfterMigration.ElementAt(6), Is.EqualTo(FileUtils.ChangePathToPlatform(@"AudioVisual\MacLeanKidsMovie.WMV")));
			Assert.That(filesPathsAfterMigration.ElementAt(7), Is.EqualTo(FileUtils.ChangePathToPlatform(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV")));
		}
Ejemplo n.º 19
0
        public void When_Confirm_is_called_then_entries_are_written_with_the_correctly_captured_timestamps()
        {
            var log = new List<LogEntry>();
            DateTime confirmTime;

            using (Log.Events().Subscribe(log.Add))
            using (var activity = Log.Enter(() => { }, requireConfirm: true))
            {
                activity.Trace("a trace");
                Thread.Sleep(2000);
                confirmTime = DateTime.UtcNow;
                Console.WriteLine(new { confirmTime });

                activity.Confirm();
            }

            Console.WriteLine("after confirm: " + log.ToLogString());

            log.ElementAt(0)
               .TimeStamp
               .AddSeconds(1)
               .Should()
               .BeBefore(confirmTime);
        }
Ejemplo n.º 20
0
        public void When_Confirm_is_called_then_entries_are_written_with_the_correctly_captured_values()
        {
            var log = new List<LogEntry>();
            var step = 1;

            using (Log.Events().Subscribe(log.Add))
            using (var activity = Log.Enter(() => new { step }, requireConfirm: true))
            {
                step++;
                activity.Trace("a trace");

                step++;
                activity.Trace(() => new { step });

                Console.WriteLine("before confirm: " + log.ToLogString());

                activity.Confirm();

                step++;
                log.Count().Should().Be(3);
            }

            Console.WriteLine("after confirm: " + log.ToLogString());

            log.ElementAt(0).ToString().Should().Contain("step = 1");
            log.ElementAt(1).ToString().Should().Contain("step = 2");
            log.ElementAt(2).ToString().Should().Contain("step = 3");
            log.ElementAt(3).ToString().Should().Contain("step = 4");
        }
        public void Given_requested_employees_are_not_in_company_When_CreateResponsibilitiesFromWizard_Then_throw_exception()
        {
            // Given
            const long anotherCompanyId = 354634234L;
            var otherCompaniesEmployees = new List<Employee>
                     {
                             new Employee() {Id = Guid.NewGuid(), CompanyId = anotherCompanyId},
                             new Employee() {Id = Guid.NewGuid(), CompanyId = anotherCompanyId},
                             new Employee() {Id = Guid.NewGuid(), CompanyId = anotherCompanyId}
                     };
            _employeeRepository
                .Setup(x => x.GetByIds(It.IsAny<List<Guid>>()))
                .Returns(otherCompaniesEmployees);

            var requestedResponsibilityFromTemplateDetails = new List<ResponsibilityFromTemplateDetail>
            {
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(0).Id, ResponsiblePersonEmployeeId = otherCompaniesEmployees.ElementAt(0).Id, FrequencyId = TaskReoccurringType.Annually },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(1).Id, ResponsiblePersonEmployeeId = otherCompaniesEmployees.ElementAt(1).Id, FrequencyId = TaskReoccurringType.ThreeYearly },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(2).Id, ResponsiblePersonEmployeeId = otherCompaniesEmployees.ElementAt(2).Id, FrequencyId = TaskReoccurringType.TwentyFourMonthly },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(3).Id, ResponsiblePersonEmployeeId = otherCompaniesEmployees.ElementAt(2).Id, FrequencyId = TaskReoccurringType.FiveYearly },
            };

            var target = GetTarget();
            var request = new CreateResponsibilityFromWizardRequest()
            {
                SiteIds = _sites.Select(x => x.Id).ToArray(),
                ResponsibilityFromTemplateDetails = requestedResponsibilityFromTemplateDetails,
                CompanyId = _companyId,
            };

            // When
            var e = Assert.Throws<EmployeeRequestedForStatutoryResponsibilityNotValidException>(() => target.CreateResponsibilitiesFromWizard(request));
        }
        public void Setup()
        {
            _companyId = 234246L;
            _responsibilityRepository = new Mock<IResponsibilityRepository>();
            _responsibilityReasonRepository = new Mock<IResponsibilityReasonRepository>();
            _responsibilityCategoryRepository = new Mock<IResponsibilityCategoryRepository>();
            _statutoryTemplateRepository = new Mock<IStatutoryResponsibilityTemplateRepository>();
            _employeeRepository = new Mock<IEmployeeRepository>();
            _siteRepository = new Mock<ISiteRepository>();
            _userForAuditingRepository = new Mock<IUserForAuditingRepository>();
            _taskCategoryRepository = new Mock<ITaskCategoryRepository>();
            _log = new Mock<IPeninsulaLog>();

            _responsibilities = new List<Responsibility>();

            _sites = new List<Site>
                     {
                         new Site { Id = 123L, ClientId = _companyId },
                         new Site { Id = 456L, ClientId = _companyId },
                         new Site { Id = 789L, ClientId = _companyId }
                     };

            _siteRepository
                .Setup(x => x.GetByIds(It.IsAny<long[]>()))
                .Returns(_sites);

            _employees = new List<Employee>
                         {
                             new Employee() {Id = Guid.NewGuid(), CompanyId = _companyId},
                             new Employee() {Id = Guid.NewGuid(), CompanyId = _companyId},
                             new Employee() {Id = Guid.NewGuid(), CompanyId = _companyId}
                         };

            _statutoryResponsibilityTemplates = new List<StatutoryResponsibilityTemplate>
                                                {
                                                    new StatutoryResponsibilityTemplate() { Id = 123L, ResponsibilityCategory = new ResponsibilityCategory { Id = 1234L }, Title = "title 1", Description = "description 1", ResponsibilityReason = new ResponsibilityReason() {Id = 1}},
                                                    new StatutoryResponsibilityTemplate() { Id = 456L, ResponsibilityCategory = new ResponsibilityCategory { Id = 534L }, Title = "title 2", Description = "description 2",  ResponsibilityReason = new ResponsibilityReason() {Id = 2}},
                                                    new StatutoryResponsibilityTemplate() { Id = 789L, ResponsibilityCategory = new ResponsibilityCategory { Id = 274L }, Title = "title 3", Description = "description 3",  ResponsibilityReason = new ResponsibilityReason() {Id = 3}},
                                                    new StatutoryResponsibilityTemplate() { Id = 1123L, ResponsibilityCategory = new ResponsibilityCategory { Id = 9434L }, Title = "title 4", Description = "description 4",  ResponsibilityReason = new ResponsibilityReason() {Id = 4}}
                                                };

            _requestedResponsibilityFromTemplateDetails = new List<ResponsibilityFromTemplateDetail>
            {
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(0).Id, ResponsiblePersonEmployeeId = _employees.ElementAt(0).Id, FrequencyId = TaskReoccurringType.Annually },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(1).Id, ResponsiblePersonEmployeeId = _employees.ElementAt(1).Id, FrequencyId = TaskReoccurringType.ThreeYearly },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(2).Id, ResponsiblePersonEmployeeId = _employees.ElementAt(2).Id, FrequencyId = TaskReoccurringType.TwentyFourMonthly },
                new ResponsibilityFromTemplateDetail() { ResponsibilityTemplateId = _statutoryResponsibilityTemplates.ElementAt(3).Id, ResponsiblePersonEmployeeId = _employees.ElementAt(2).Id, FrequencyId = TaskReoccurringType.FiveYearly },
            };

            _employeeRepository
                .Setup(x => x.GetByIds(It.IsAny<IList<Guid>>()))
                .Returns(_employees.Where(x =>
                    _requestedResponsibilityFromTemplateDetails.Select(y => y.ResponsiblePersonEmployeeId).Distinct().Contains(x.Id)
                ));

            _statutoryTemplateRepository
                .Setup(x => x.GetByIds(It.IsAny<IList<long>>()))
                .Returns(_statutoryResponsibilityTemplates);

            _responsibilityRepository
                .Setup(x => x.Save(It.IsAny<Responsibility>()));

            _responsibilityRepository
                .Setup(x => x.GetStatutoryByCompanyId(It.IsAny<long>()))
                .Returns(_responsibilities);

            _responsibilityCategoryRepository
                .Setup(x => x.GetByIds(It.IsAny<IList<long>>()))
                .Returns(_responsibilityCategories);

            _testUser = new UserForAuditing() { CompanyId = _companyId, Id = Guid.NewGuid() };

            _userForAuditingRepository
                .Setup(x => x.GetByIdAndCompanyId(It.IsAny<Guid>(), It.IsAny<long>()))
                .Returns(_testUser);
        }
Ejemplo n.º 23
0
		private void CheckCmFilePathsBeforeMigration(List<string> filesPaths)
		{
			Assert.That(filesPaths.ElementAt(0), Is.EqualTo(@"Pictures\RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(1), Is.EqualTo(@"Pictures\Jude1.jpg"));
			Assert.That(filesPaths.ElementAt(2), Is.EqualTo(@"RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(3), Is.EqualTo(@"C:\FwWW\DistFiles\RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(4), Is.EqualTo(@"Pictures\Rick USVI.jpg"));
			Assert.That(filesPaths.ElementAt(5), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
			Assert.That(filesPaths.ElementAt(6), Is.EqualTo(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV"));
		}
Ejemplo n.º 24
0
		private void CheckCmFilePathsAfterMigration(List<string> filesPaths)
		{
			//Now check to ensure CmFile paths that existed before the migration are still there.

			Assert.That(filesPaths.ElementAt(0), Is.EqualTo(@"Pictures\RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(1), Is.EqualTo(@"Pictures\Jude1.jpg"));
			Assert.That(filesPaths.ElementAt(2), Is.EqualTo(@"RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(3), Is.EqualTo(@"C:\FwWW\DistFiles\RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(4), Is.EqualTo(@"Pictures\Rick USVI.jpg"));
			Assert.That(filesPaths.ElementAt(5), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
			Assert.That(filesPaths.ElementAt(6), Is.EqualTo(@"C:\FwWW\DistFiles\AudioVisual\NotInLinkedFilesPath.WMV"));

			//Also ensure new CmFile paths are created based on all the file paths found.  This should be a new test really since they will be found
			//inside the FilePathsInTsStrings LangProject element.
			Assert.That(filesPaths.ElementAt(7), Is.EqualTo(@"Pictures\RickKayak.jpg"));
			Assert.That(filesPaths.ElementAt(8), Is.EqualTo(@"Pictures\Jude1.jpg"));
			Assert.That(filesPaths.ElementAt(9), Is.EqualTo(@"Others\LukeGrad-BW.pdf"));
			Assert.That(filesPaths.ElementAt(10), Is.EqualTo(@"Pictures\Rick USVI.jpg"));
			Assert.That(filesPaths.ElementAt(11), Is.EqualTo(FileUtils.ChangeWindowsPathIfLinux(@"Others\LukeGrad-BW.pdf")));
			Assert.That(filesPaths.ElementAt(12), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
			Assert.That(filesPaths.ElementAt(13), Is.EqualTo(FileUtils.ChangeWindowsPathIfLinux(@"C:\FwWW\Users\CuriousGeorge\Babar\NotInLinkedFilesPath.mov")));
			Assert.That(filesPaths.ElementAt(14), Is.EqualTo(FileUtils.ChangeWindowsPathIfLinux(@"Pictures\RickKayak.jpg")));
			Assert.That(filesPaths.ElementAt(15), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
		}
        public void When_GetViewModel_called_with_CreateRiskAssessmentViewModel_Then_hazardous_substances_are_put_in_view_model()
        {
            // Given
            var returnedHazardousSubstances = new List<HazardousSubstanceDto>()
                                              {
                                                  new HazardousSubstanceDto() { Id = 1, Name = "hazsub 01"},
                                                  new HazardousSubstanceDto() { Id = 2, Name = "hazsub 02" },
                                                  new HazardousSubstanceDto() { Id = 3, Name = "hazsub 03" },
                                                  new HazardousSubstanceDto() { Id = 4, Name = "hazsub 04" }
                                              };

            var createRiskAssessmentViewModel = new CreateRiskAssessmentViewModel()
                                                {

                                                };

            _hazardousSubstanceService
                .Setup(x => x.Search(It.IsAny<SearchHazardousSubstancesRequest>()))
                .Returns(returnedHazardousSubstances);

            // When
            var result = _target.WithCompanyId(1234).GetViewModel(createRiskAssessmentViewModel) as CreateRiskAssessmentViewModel;

            // Then
            Assert.That(result.HazardousSubstances.Count(), Is.EqualTo(5));
            for (var i = 1; i < returnedHazardousSubstances.Count; i++)
            {
                Assert.That(result.HazardousSubstances.ElementAt(i).label, Is.EqualTo(returnedHazardousSubstances.ElementAt(i - 1).Name));
                Assert.That(result.HazardousSubstances.ElementAt(i).value, Is.EqualTo(returnedHazardousSubstances.ElementAt(i - 1).Id.ToString()));
            }
        }
Ejemplo n.º 26
0
        private void ValidateNUCmerAlignGeneralTestCases(string nodeName, bool isFilePath, bool isAlignList, AdditionalParameters addParam,
                                                         PropertyParameters propParam, bool isAmbiguous)
        {
            IList<ISequence> refSeqList = new List<ISequence>();
            IList<ISequence> searchSeqList = new List<ISequence>();

            if (isFilePath)
            {
                // Gets the reference sequence from the FastA file
                string filePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);

                Assert.IsNotNull(filePath);
                ApplicationLog.WriteLine(string.Format(null, "NUCmer P1 : Successfully validated the File Path '{0}'.", filePath));

                var fastaparserobj = new FastAParser();
                IEnumerable<ISequence> referenceSeqList = fastaparserobj.Parse(filePath);

                foreach (ISequence seq in referenceSeqList)
                {
                    refSeqList.Add(seq);
                }

                // Gets the query sequence from the FastA file
                string queryFilePath = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);

                Assert.IsNotNull(queryFilePath);
                ApplicationLog.WriteLine(string.Format(null, "NUCmer P1 : Successfully validated the File Path '{0}'.", queryFilePath));

                var queryParserobj = new FastAParser();
                IEnumerable<ISequence> serSeqList = queryParserobj.Parse(queryFilePath);

                foreach (ISequence seq in serSeqList)
                {
                    searchSeqList.Add(seq);
                }
            }
            else
            {
                // Gets the reference & search sequences from the configuration file
                string[] referenceSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ReferenceSequencesNode);
                string[] searchSequences = this.utilityObj.xmlUtil.GetTextValues(nodeName, Constants.SearchSequencesNode);

                IAlphabet seqAlphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNode));
                IAlphabet ambAlphabet = null;
                if (isAmbiguous)
                {
                    switch (seqAlphabet.Name.ToLower(CultureInfo.CurrentCulture))
                    {
                        case "dna":
                        case "ambiguousdna":
                            ambAlphabet = AmbiguousDnaAlphabet.Instance;
                            break;
                        case "rna":
                        case "ambiguousrna":
                            ambAlphabet = AmbiguousRnaAlphabet.Instance;
                            break;
                        case "protein":
                        case "ambiguousprotein":
                            ambAlphabet = AmbiguousProteinAlphabet.Instance;
                            break;
                        default:
                            break;
                    }
                }
                else
                {
                    ambAlphabet = seqAlphabet;
                }

                for (int i = 0; i < referenceSequences.Length; i++)
                {
                    ISequence referSeq = new Sequence(ambAlphabet,
                                                      Encoding.ASCII.GetBytes(referenceSequences[i]));
                    referSeq.ID = "ref " + i;
                    refSeqList.Add(referSeq);
                }

                for (int i = 0; i < searchSequences.Length; i++)
                {
                    ISequence searchSeq = new Sequence(ambAlphabet,
                                                       Encoding.ASCII.GetBytes(searchSequences[i]));
                    searchSeq.ID = "qry " + i;
                    searchSeqList.Add(searchSeq);
                }
            }
            // Gets the mum length from the xml
            string mumLength = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);

            var nucmerObj = new NucmerPairwiseAligner();
            // Check for additional parameters and update the object accordingly
            switch (addParam)
            {
                case AdditionalParameters.AlignSimilarityMatrix:
                    nucmerObj.SimilarityMatrix = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.Blosum50);
                    break;
                default:
                    break;
            }
            // Update other values for NUCmer object
            nucmerObj.MaximumSeparation = 0;
            nucmerObj.MinimumScore = 2;
            nucmerObj.SeparationFactor = 0.12f;
            nucmerObj.BreakLength = 2;
            nucmerObj.LengthOfMUM = long.Parse(mumLength, null);

            switch (propParam)
            {
                case PropertyParameters.MinimumScore:
                    nucmerObj.MinimumScore = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MinimumScoreNode), null);
                    break;
                case PropertyParameters.MaximumSeparation:
                    nucmerObj.MaximumSeparation = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null);
                    break;
                case PropertyParameters.FixedSeparation:
                    nucmerObj.FixedSeparation = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                case PropertyParameters.SeparationFactor:
                    nucmerObj.SeparationFactor = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    break;
                case PropertyParameters.FixedSeparationAndSeparationFactor:
                    nucmerObj.SeparationFactor = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    nucmerObj.FixedSeparation = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                case PropertyParameters.MaximumFixedAndSeparationFactor:
                    nucmerObj.MaximumSeparation = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MaximumSeparationNode), null);
                    nucmerObj.SeparationFactor = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeparationFactorNode), null);
                    nucmerObj.FixedSeparation = int.Parse(
                        this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FixedSeparationNode), null);
                    break;
                default:
                    break;
            }

            IList<ISequenceAlignment> align = null;

            if (isAlignList)
            {
                var listOfSeq = new List<ISequence> {refSeqList.ElementAt(0), searchSeqList.ElementAt(0)};
                align = nucmerObj.Align(listOfSeq);
            }
            else
            {
                align = nucmerObj.Align(refSeqList, searchSeqList);
            }

            string expectedSequences = isFilePath
                    ? this.utilityObj.xmlUtil.GetFileTextValue(nodeName, Constants.ExpectedSequencesNode)
                    : this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequencesNode);
            string[] expSeqArray = expectedSequences.Split(',');

            // Gets all the aligned sequences in comma separated format
            foreach (IPairwiseSequenceAlignment seqAlignment in align)
            {
                foreach (PairwiseAlignedSequence alignedSeq in seqAlignment)
                {
                    var actualStr = alignedSeq.FirstSequence.ConvertToString();
                    Assert.IsTrue(expSeqArray.Contains(actualStr));

                    actualStr = alignedSeq.SecondSequence.ConvertToString();
                    Assert.IsTrue(expSeqArray.Contains(actualStr));
                }
            }

            ApplicationLog.WriteLine("NUCmer P1 : Successfully validated all the aligned sequences.");
        }
Ejemplo n.º 27
0
        /// <summary>
        /// General verifier for codefixes.
        /// Creates a Document from the source string, then gets diagnostics on it and applies the relevant codefixes.
        /// Then gets the string after the codefix is applied and compares it with the expected result.
        /// Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true.
        /// </summary>
        /// <param name="language">The language the source code is in</param>
        /// <param name="analyzer">The analyzer to be applied to the source code</param>
        /// <param name="codeFixProvider">The codefix to be applied to the code wherever the relevant Diagnostic is found</param>
        /// <param name="oldSource">A class in the form of a string before the CodeFix was applied to it</param>
        /// <param name="newSource">A class in the form of a string after the CodeFix was applied to it</param>
        /// <param name="codeFixIndex">Index determining which codefix to apply if there are multiple</param>
        /// <param name="allowNewCompilerDiagnostics">A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied</param>
        private void VerifyFix(string language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex, bool allowNewCompilerDiagnostics)
        {
            var document = CreateDocument(oldSource, language);
            var analyzerDiagnostics = GetSortedDiagnosticsFromDocuments(analyzer, new[] { document });
            var compilerDiagnostics = GetCompilerDiagnostics(document);
            var attempts = analyzerDiagnostics.Length;

            for (int i = 0; i < attempts; ++i)
            {
                var actions = new List<CodeAction>();
                var context = new CodeFixContext(document, analyzerDiagnostics[0], (a, d) => actions.Add(a), CancellationToken.None);
                codeFixProvider.RegisterCodeFixesAsync(context).Wait();

                if (!actions.Any())
                {
                    break;
                }

                if (codeFixIndex != null)
                {
                    document = ApplyFix(document, actions.ElementAt((int)codeFixIndex));
                    break;
                }

                document = ApplyFix(document, actions.ElementAt(0));
                analyzerDiagnostics = GetSortedDiagnosticsFromDocuments(analyzer, new[] { document });

                var newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));

                //check if applying the code fix introduced any new compiler diagnostics
                if (!allowNewCompilerDiagnostics && newCompilerDiagnostics.Any())
                {
                    // Format and get the compiler diagnostics again so that the locations make sense in the output
                    document = document.WithSyntaxRoot(Formatter.Format(document.GetSyntaxRootAsync().Result, Formatter.Annotation, document.Project.Solution.Workspace));
                    newCompilerDiagnostics = GetNewDiagnostics(compilerDiagnostics, GetCompilerDiagnostics(document));

                    Assert.Fail(
                        string.Format("Fix introduced new compiler diagnostics:\r\n{0}\r\n\r\nNew document:\r\n{1}\r\n",
                            string.Join("\r\n", newCompilerDiagnostics.Select(d => d.ToString())),
                            document.GetSyntaxRootAsync().Result.ToFullString()));
                }

                //check if there are analyzer diagnostics left after the code fix
                if (!analyzerDiagnostics.Any())
                {
                    break;
                }
            }

            //after applying all of the code fixes, compare the resulting string to the inputted one
            var actual = GetStringFromDocument(document);
            Assert.AreEqual(newSource, actual);
        }
Ejemplo n.º 28
0
        public async void Calendars_AddOrUpdateEvents_UpdatesEvents()
        {
            // TODO: Test description

            var originalEvents = new List<CalendarEvent> {
                new CalendarEvent { Name = "Bob", Description = "Bob's event", Start = DateTime.Today.AddDays(5), End = DateTime.Today.AddDays(5).AddHours(2), AllDay = false },
                new CalendarEvent { Name = "Steve", Description = "Steve's event", Start = DateTime.Today.AddDays(7), End = DateTime.Today.AddDays(8), AllDay = true },
                new CalendarEvent { Name = "Wheeee", Description = "Fun times", Start = DateTime.Today.AddDays(13), End = DateTime.Today.AddDays(15), AllDay = true }
            };
            var editedEvents = new List<CalendarEvent> {
                new CalendarEvent { Name = "Bob (edited)", Description = "Bob's edited event", Start = DateTime.Today.AddDays(5).AddHours(-2), End = DateTime.Today.AddDays(5).AddHours(1), AllDay = false },
                new CalendarEvent { Name = "Steve (edited)", Description = "Steve's edited event", Start = DateTime.Today.AddDays(6), End = DateTime.Today.AddDays(7).AddHours(-1), AllDay = false },
                new CalendarEvent { Name = "Yay (edited)", Description = "Edited fun times", Start = DateTime.Today.AddDays(12), End = DateTime.Today.AddDays(13), AllDay = true }
            };
            var calendar = new Calendar { Name = _calendarName };
            var queryStartDate = DateTime.Today;
            var queryEndDate = queryStartDate.AddDays(30);

            await _service.AddOrUpdateCalendarAsync(calendar);

            //await _service.AddOrUpdateEventsAsync(calendar, originalEvents);
            foreach (var cev in originalEvents)
            {
                await _service.AddOrUpdateEventAsync(calendar, cev);
            }

            var eventResults = await _service.GetEventsAsync(calendar, queryStartDate, queryEndDate);

            Assert.That(eventResults, Is.EqualTo(originalEvents).Using<CalendarEvent>(_eventComparer));


            for (int i = 0; i < eventResults.Count; i++)
            {
                editedEvents.ElementAt(i).ExternalID = eventResults.ElementAt(i).ExternalID;
            }

            //await _service.AddOrUpdateEventsAsync(calendar, editedEvents);
            foreach (var cev in editedEvents)
            {
                await _service.AddOrUpdateEventAsync(calendar, cev);
            }

            var editedEventResults = await _service.GetEventsAsync(calendar, queryStartDate, queryEndDate);

            Assert.That(editedEventResults, Is.EqualTo(editedEvents).Using<CalendarEvent>(_eventComparer));
        }
        public void When_GetViewModel_Then_hazardous_substances_are_put_in_view_model_and_prepends_please_select_empty_option()
        {
            // Given
            var returnedHazardousSubstances = new List<HazardousSubstanceDto>()
                                              {
                                                  new HazardousSubstanceDto() { Id = 1, Name = "hazsub 01"},
                                                  new HazardousSubstanceDto() { Id = 2, Name = "hazsub 02" },
                                                  new HazardousSubstanceDto() { Id = 3, Name = "hazsub 03" },
                                                  new HazardousSubstanceDto() { Id = 4, Name = "hazsub 04" }
                                              };
            _hazardousSubstanceService
                .Setup(x => x.Search(It.IsAny<SearchHazardousSubstancesRequest>()))
                .Returns(returnedHazardousSubstances);

            // When
            var result = _target.WithCompanyId(1234).GetViewModel();

            // Then
            Assert.That(result.HazardousSubstances.Count(), Is.EqualTo(5));
            Assert.That(result.HazardousSubstances.First().value, Is.EqualTo(string.Empty));
            Assert.That(result.HazardousSubstances.First().label, Is.EqualTo("--Select Option--"));
            for (var i = 1; i < returnedHazardousSubstances.Count; i++)
            {
                Assert.That(result.HazardousSubstances.Skip(i).Take(1).First().label, Is.EqualTo(returnedHazardousSubstances.ElementAt(i - 1).Name));
                Assert.That(result.HazardousSubstances.Skip(i).Take(1).First().value, Is.EqualTo(returnedHazardousSubstances.ElementAt(i - 1).Id.ToString()));
            }
        }
Ejemplo n.º 30
0
		private void CheckExternalLinksInTsStringsAfterMigration(List<string> filesPathsInTsStringsAfterMigration)
		{
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(0), Is.EqualTo(@"http:\www.efccm.ca\wordpress\"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(1), Is.EqualTo(@"silfw:\localhost\link?app%3dflex%26database%3dc%3a%5cFwWW%5cDistFiles%5cProjects%5cSena+3%5cSena+3.fwdata%26tool%3dlexiconEdit%26guid%3da15b8ae6-207c-4999-b1e0-f95a348d1bdc%26tag%3d"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(2), Is.EqualTo(@"Pictures\RickKayak.jpg"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(3), Is.EqualTo(@"Pictures\Jude1.jpg"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(4), Is.EqualTo(@"Others\LukeGrad-BW.pdf"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(5), Is.EqualTo(@"Pictures\Rick USVI.jpg"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(6), Is.EqualTo(FileUtils.ChangeWindowsPathIfLinux(@"Others\LukeGrad-BW.pdf")));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(7), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(8), Is.EqualTo(@"C:\FwWW\Users\CuriousGeorge\Babar\NotInLinkedFilesPath.mov"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(9), Is.EqualTo(@"http://icoder.wordpress.com/2008/11/12/how-to-collapse-all-projects-in-a-visual-studio-2008-solution/"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(10), Is.EqualTo(@" http://icoder.wordpress.com/2008/11/12/how-to-collapse-all-projects-in-a-visual-studio-2008-solution/"));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(11), Is.EqualTo(FileUtils.ChangeWindowsPathIfLinux(@"Pictures\RickKayak.jpg")));
			Assert.That(filesPathsInTsStringsAfterMigration.ElementAt(12), Is.EqualTo(@"AudioVisual\Untitled5.WMV"));
		}