public void TestAddRooms() { AdditionalMethods model = new AdditionalMethods(); model.AddRooms(RoomType.single); Assert.AreEqual(1, model.DisplayRooms().Count); }
/// <summary> /// Check the number of MainBlocks that may own the given Cell. /// Can proves no solution, mark a Cell as owned or set a possible block as a solution to a MainBlock. /// </summary> private bool CountCellPossibleOwners(ICell cell) { //There are no MainBlocks that can contain the Cell, hence there can be no solution. if (cell.GetPossibleMainBlocks.Count == 0) { return(true); } //There is only 1 MainBlock that can contain this Cell, hence the Cell must be owned by said MainBlock. //If there is also only 1 PossibleOwner for this MainBlock, that PossibleBlock must be the solution to the MainBlock. if (cell.GetPossibleMainBlocks.Count == 1) { if (cell.GetPossibleOwners[cell.GetPossibleMainBlocks.First.Value].Count == 1) { if (_ownershipSetter.SetPossibleBlockAsSolution(AdditionalMethods.CreatePossibleBlockFromIndex( cell.GetPossibleMainBlocks.First.Value, _solutionTracker.BlockDimensionSets, cell.GetPossibleOwners[cell.GetPossibleMainBlocks.First.Value].First.Value))) { return(true); } } else { if (_ownershipSetter.MarkCellAsOwned(cell, cell.GetPossibleMainBlocks.First.Value)) { return(true); } } } return(false); }
public void TestNowyPensjonat() { AdditionalMethods model = new AdditionalMethods(); Assert.AreEqual(0, model.DisplayGuests().Count); Assert.AreEqual(0, model.DisplayRooms().Count); }
public void TestAdd() { var vm = new MaintenanceFormViewModel(true); var model = new AdditionalMethods(); vm.IdRobocze = 1; vm.Init(); }
public void TestAddGuest() { AdditionalMethods model = new AdditionalMethods(); model.AddGuest("Łucja", "Wołkowicz", "Polish"); Assert.AreEqual(1, model.DisplayGuests().Count); Assert.AreEqual(0, model.DisplayRooms().Count); }
public void TestReservation() { AdditionalMethods model = new AdditionalMethods(); model.AddGuest("Łucja", "Wołkowicz", "Polish"); model.DisplayRooms().Add(new Room(1, 200, RoomType.doublebed)); model.AddReservation(1, RoomType.doublebed); Assert.AreEqual(1, model.DisplayGuests()[0].NrofRoom); }
/// <summary> /// Considers a single MainBlock at a time. /// </summary> private void ProcessMainBlock(IMainBlock mainBlock) { int dimensionSetIndex = 0; while (dimensionSetIndex < _solutionTracker.BlockDimensionSets[mainBlock.Capacity].Count) { PossibleBlock = AdditionalMethods.CreatPossibleBlockFromDimensionSetIndex(mainBlock, _solutionTracker.BlockDimensionSets, dimensionSetIndex); ProcessDimensionSet(); dimensionSetIndex++; } }
private void TestUpdate_Click(object sender, EventArgs e) { Indexes.Clear(); indexesLength = 0; CurrentSearchIndex = 0; var transforms = Transformations.Select(x => new TrackedTransformation { Method = x }).ToArray(); int updatedVideos = 0; foreach (var video in Videos) { bool updated = false; foreach (var transformation in transforms) { var transformResult = AdditionalMethods.DoReplacements(video.DisplayDescription, transformation.Method); if (transformResult.Item2) { updated = true; video.DisplayDescription = transformResult.Item4; transformation.TransformCount += transformResult.Item3; } } if (updated) { updatedVideos++; } } UpdateDescriptions.Text = $"Upload {updatedVideos} Changes"; var response = $"Test Updated {updatedVideos} videos\r\n"; foreach (var transform in transforms) { if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Replace) { response += $"Replaced {transform.TransformCount} occurrences of {transform.Method.PrimaryValue} with {transform.Method.SecondaryValue}\r\n"; } else if (transform.Method.Method == AdditionalMethods.StringTransformation.TransformationMethod.Remove) { response += $"Removed {transform.TransformCount} occurrences of {transform.Method.PrimaryValue}\r\n"; } } VideoInformation.Text = NewLineFix(string.Join("\r\n----------\r\n", Videos.Select(x => $"Title: {x.Video.Snippet.Title} ({x.Video.Id})\r\n----------\r\n{x.DisplayDescription}"))); LogMessage("Tested Descriptions update."); LogMessage(response); UpdateDescriptionTextChange(); }
public static void Main() { var substr = AdditionalMethods.Subsequence("Hello!".ToCharArray(), 2, 3); Console.WriteLine(substr); var subarr = AdditionalMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 2); Console.WriteLine(string.Join(" ", subarr)); var allarr = AdditionalMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 4); Console.WriteLine(string.Join(" ", allarr)); //// Uncomment to see the exception //// var emptyarr = AdditionalMethods.Subsequence(new int[] { -1, 3, 2, 1 }, 0, 0); //// Console.WriteLine(string.Join(" ", emptyarr)); Console.WriteLine(AdditionalMethods.ExtractEnding("I love C#", 2)); Console.WriteLine(AdditionalMethods.ExtractEnding("Nakov", 4)); Console.WriteLine(AdditionalMethods.ExtractEnding("beer", 4)); //// Uncomment to see the exception //// Console.WriteLine(AdditionalMethods.ExtractEnding("Hi", 100)); //// Console.WriteLine(AdditionalMethods.ExtractEnding("", 0)); try { AdditionalMethods.CheckPrime(23); AdditionalMethods.CheckPrime(33); AdditionalMethods.CheckPrime(1); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine("Invalid number - {0}", ex); } List <Exam> peterExams = new List <Exam>() { new SimpleMathExam(2), new CSharpExam(55), new CSharpExam(100), new SimpleMathExam(1), new CSharpExam(0), }; Student peter = new Student("Peter", "Petrov", peterExams); double peterAverageResult = peter.CalcAverageExamResultInPercents(); Console.WriteLine("Average results = {0:p0}", peterAverageResult); }
private void WarehouseResetButton_Click(object sender, RoutedEventArgs e) { var grid = _mainWindow.LinearGrid.IsVisible; var warehouse = AdditionalMethods.ParseCustomWarehouse(WarehouseTextBox.Text, ";", !grid); if (grid) { _mainWindow.LinearWarehouse = warehouse; _mainWindow.LinearDataGrid.ItemsSource = _mainWindow.LinearWarehouse.WarehouseSlots; } else { _mainWindow.RotatingWarehouse = warehouse; _mainWindow.RotatingDataGrid.ItemsSource = _mainWindow.RotatingWarehouse.WarehouseSlots; } }
private bool CheckMainBlocks(List <IMainBlock> mainBlocks) { if (mainBlocks == null) { return(true); } else { foreach (IMainBlock mainBlock in mainBlocks) { foreach (int possibleBlock in mainBlock.PossibleBlocks) { SetPossibleBlockAsSolution(AdditionalMethods.CreatePossibleBlockFromIndex(mainBlock, _solutionTracker.BlockDimensionSets, possibleBlock)); } } } return(false); }
public static Warehouse RandomPopulateWarehouse(int numberOfItems, bool isRotary) { var random = new Random(); var warehouse = new Warehouse(numberOfItems, isRotary); for (var i = 0; i < numberOfItems; i++) { if (random.Next(0, 10) > 1) { warehouse.AddItemToList(i, new Item(string.Empty, 0)); continue; } warehouse.AddItemToList(i, new Item(AdditionalMethods.RandomString(10), 1)); } return(warehouse); }
public RightCommandTests() { _helper = new AdditionalMethods(); }
public WinCheckersTest() { _helper = new AdditionalMethods(); }
public DownCommandTests() { _helper = new AdditionalMethods(); }