diff --git a/CleanCode/Ejemplos/ConditionalTofunct/ConditionalTofunct.csproj b/CleanCode/Ejemplos/ConditionalTofunct/ConditionalTofunct.csproj new file mode 100644 index 0000000..b9de063 --- /dev/null +++ b/CleanCode/Ejemplos/ConditionalTofunct/ConditionalTofunct.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/CleanCode/Ejemplos/ConditionalTofunct/PlaceHolder.cs b/CleanCode/Ejemplos/ConditionalTofunct/PlaceHolder.cs new file mode 100644 index 0000000..47d48ee --- /dev/null +++ b/CleanCode/Ejemplos/ConditionalTofunct/PlaceHolder.cs @@ -0,0 +1,23 @@ +using System.Security.Cryptography.X509Certificates; + +namespace ConditionalTofunct; + +public class PlaceHolder +{ + public DateTime FechaExpiracion { get; set; } + public bool AprobadoParaConsumo { get; set; } + public int IdInspector { get; set; } + + public bool IsComestible() + { + if (FechaExpiracion > DateTime.Now && AprobadoParaConsumo + && AprobadoParaConsumo == true && IdInspector !=0) + { + return true; + } + else + { + return false; + } + } +} \ No newline at end of file diff --git a/CleanCode/Ejemplos/ConditionalTofunct/Program.cs b/CleanCode/Ejemplos/ConditionalTofunct/Program.cs new file mode 100644 index 0000000..e5dff12 --- /dev/null +++ b/CleanCode/Ejemplos/ConditionalTofunct/Program.cs @@ -0,0 +1,3 @@ +// See https://aka.ms/new-console-template for more information + +Console.WriteLine("Hello, World!"); \ No newline at end of file diff --git a/CleanCode/Ejemplos/Ejemplos.sln b/CleanCode/Ejemplos/Ejemplos.sln index abba0e3..f0df51b 100644 --- a/CleanCode/Ejemplos/Ejemplos.sln +++ b/CleanCode/Ejemplos/Ejemplos.sln @@ -12,6 +12,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactorCleanCodeTests", "R EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactorCleanCodeSource", "RefactorCleanCodeSource\RefactorCleanCodeSource.csproj", "{F688DAE3-C6B5-456B-8540-62B970442062}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConditionalTofunct", "ConditionalTofunct\ConditionalTofunct.csproj", "{0927109E-E341-4171-9551-89900ABBBEB5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -42,5 +44,9 @@ Global {F688DAE3-C6B5-456B-8540-62B970442062}.Debug|Any CPU.Build.0 = Debug|Any CPU {F688DAE3-C6B5-456B-8540-62B970442062}.Release|Any CPU.ActiveCfg = Release|Any CPU {F688DAE3-C6B5-456B-8540-62B970442062}.Release|Any CPU.Build.0 = Release|Any CPU + {0927109E-E341-4171-9551-89900ABBBEB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0927109E-E341-4171-9551-89900ABBBEB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0927109E-E341-4171-9551-89900ABBBEB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0927109E-E341-4171-9551-89900ABBBEB5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/CleanCode/Ejemplos/WithoutDemeter/Program.cs b/CleanCode/Ejemplos/WithoutDemeter/Program.cs index 0f4bf42..3a02629 100644 --- a/CleanCode/Ejemplos/WithoutDemeter/Program.cs +++ b/CleanCode/Ejemplos/WithoutDemeter/Program.cs @@ -2,8 +2,8 @@ using Ejemplos; -Commerce commerce = new Commerce(); +Store store = new Store(); Customer customer = new Customer(); Wallet w = customer.Wallet; w.Money = 100; -commerce.Checkout(customer, 110); +store.Checkout(customer, 110); diff --git a/CleanCode/Ejemplos/WithoutDemeter/Commerce.cs b/CleanCode/Ejemplos/WithoutDemeter/Store.cs similarity index 94% rename from CleanCode/Ejemplos/WithoutDemeter/Commerce.cs rename to CleanCode/Ejemplos/WithoutDemeter/Store.cs index f1dc811..1d4384d 100644 --- a/CleanCode/Ejemplos/WithoutDemeter/Commerce.cs +++ b/CleanCode/Ejemplos/WithoutDemeter/Store.cs @@ -1,6 +1,6 @@ namespace Ejemplos; -public class Commerce +public class Store { public void Checkout(Customer customer, decimal amount) { diff --git a/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/OriginalCode.csproj b/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/OriginalCode.csproj new file mode 100644 index 0000000..6836c68 --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/OriginalCode.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/operations_on_numbers.cs b/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/operations_on_numbers.cs new file mode 100644 index 0000000..1731ec4 --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/OriginalCode/operations_on_numbers.cs @@ -0,0 +1,34 @@ +namespace OriginalCode; + +public class operations_on_numbers +{ + private int total; + private int contador; + + public operations_on_numbers() + { + total = 0; + contador = 0; + } + + public int magic_function(List ns) + { + foreach (int n in ns) + { + if (n % 2 == 0) + { + total += n; + contador++; + } + } + + if (contador == 0) + { + throw new Exception("La lista no contiene numeros pares "); + } + else + { + return total / contador; + } + } +} \ No newline at end of file diff --git a/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamples.sln b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamples.sln new file mode 100644 index 0000000..d4ccd4e --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamples.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToRefactorExamples", "ToRefactorExamples\ToRefactorExamples.csproj", "{FE7BCF27-1F9C-4A46-AF71-944539A34BF1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RefactoringExamplesTests", "RefactoringExamplesTests\RefactoringExamplesTests.csproj", "{4A1F1396-469A-44CF-A84F-5AF1164ABAF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OriginalCode", "OriginalCode\OriginalCode.csproj", "{C214ABEA-E7C3-435D-A89D-1C74A1D34029}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FE7BCF27-1F9C-4A46-AF71-944539A34BF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE7BCF27-1F9C-4A46-AF71-944539A34BF1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE7BCF27-1F9C-4A46-AF71-944539A34BF1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE7BCF27-1F9C-4A46-AF71-944539A34BF1}.Release|Any CPU.Build.0 = Release|Any CPU + {4A1F1396-469A-44CF-A84F-5AF1164ABAF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A1F1396-469A-44CF-A84F-5AF1164ABAF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A1F1396-469A-44CF-A84F-5AF1164ABAF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A1F1396-469A-44CF-A84F-5AF1164ABAF9}.Release|Any CPU.Build.0 = Release|Any CPU + {C214ABEA-E7C3-435D-A89D-1C74A1D34029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C214ABEA-E7C3-435D-A89D-1C74A1D34029}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C214ABEA-E7C3-435D-A89D-1C74A1D34029}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C214ABEA-E7C3-435D-A89D-1C74A1D34029}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringExamplesTests.csproj b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringExamplesTests.csproj new file mode 100644 index 0000000..a7ab0b7 --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringExamplesTests.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringTests.cs b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringTests.cs new file mode 100644 index 0000000..68791f9 --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/RefactoringTests.cs @@ -0,0 +1,88 @@ +using ToRefactorExamples; + +namespace RefactoringExamplesTests; + +public class RefactoringTests +{ + [Fact] + public void Should_Return_the_Average_Given_a_Set_Of_One_Even_Number() + { + List numbers = new() {8}; + operations_on_numbers rf = new operations_on_numbers(); + int want = 8; + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Return_The_Average_Given_a_Set_Of_Two_Even_Numbers() + { + List numbers = new() { 2, 6 }; + operations_on_numbers rf = new operations_on_numbers(); + int want = 4; + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Return_The_Even_Number_Given_A_SetWith_One_Even_And_One_Odd_Number() + { + List numbers = new() { 2, 7 }; + operations_on_numbers rf = new operations_on_numbers(); + int want = 2; + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Return_The_Even_Number_Given_A_SetWith_More_Than_One_Even_And_One_Odd_Number() + { + List numbers = new() {0, 2, 7 }; + operations_on_numbers rf = new operations_on_numbers(); + int want = 1; + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Return_TheAverage_Given_An_Odd_SetOf_Even_Numbers_Including_Zero() + { + List numbers = new() {0, 2, 6, 8, 12, 24, 28 }; + operations_on_numbers rf = new operations_on_numbers(); + int want = Convert.ToInt32(numbers.Average()); + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Return_TheAverage_Given_ASetOf_Even_Numbers_Containing_a_Cero() + { + List numbers = new() {0, 6, 8, 12, 24, 28 }; + operations_on_numbers rf = new operations_on_numbers(); + int want = Convert.ToInt32(numbers.Average()); + int got = rf.magic_function(numbers); + Assert.Equal(want, got); + } + + [Fact] + public void Should_Throw_ArgumentExcep_Given_An_Empty_Set() + { + List numbers = new(); + operations_on_numbers rf = new operations_on_numbers(); + + // Renombre para usar la ArgumentException + Assert.Throws(() => rf.magic_function(numbers)); + } + + [Fact] + public void Should_Return_Message_Given_ASet_of_Odd_Numbers() + { + List numbers = new() { 1, 5, 7,35 }; + operations_on_numbers rf = new operations_on_numbers(); + string want = "La lista no contiene numeros pares"; + var got = Assert.Throws(() => rf.magic_function(numbers)); + Assert.Contains(want, got.Message); + } + + +} \ No newline at end of file diff --git a/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/Usings.cs b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/RefactoringExamplesTests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/ToRefactorExamples.csproj b/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/ToRefactorExamples.csproj new file mode 100644 index 0000000..6836c68 --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/ToRefactorExamples.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/operations_on_numbers.cs b/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/operations_on_numbers.cs new file mode 100644 index 0000000..69f010e --- /dev/null +++ b/TDD/RefactoringExamples/RefactoringExamples/ToRefactorExamples/operations_on_numbers.cs @@ -0,0 +1,44 @@ +namespace ToRefactorExamples; + +/* - Cambiar todos los Nombres no significativos a significativos. + * - Utilizar la convención de C# de programación y en Ingles + * - Refactoree y aplique Clean Code en todo el código + * ->reemplazar números magicos + * ->reemplazar comentarios por nombres significativos + * -> extraer métodos + * + */ +public class operations_on_numbers +{ + private int total; + private int contador; + + public operations_on_numbers() + { + total = 0; + contador = 0; + } + + public int magic_function(List ns) + { + foreach (int n in ns) + { + if (n % 2 == 0) + { + total += n; + contador++; + } + } + + if (contador == 0) + { + throw new Exception("La lista no contiene numeros pares "); + } + else + { + return total / contador; + } + } +} + + diff --git a/TDD/practica2023_1/docs/FizBuzz.txt b/TDD/practica2023_1/docs/FizBuzz.txt index 603f850..61d4924 100644 --- a/TDD/practica2023_1/docs/FizBuzz.txt +++ b/TDD/practica2023_1/docs/FizBuzz.txt @@ -9,16 +9,17 @@ * Crear una clase que tenga un método que dado un número retorne: Fizz si el número es divisible por 3 Buzz si el número es divisible por 5 - FizzBuzzLogic si el número es divisible por 3 y 5 - Si el número no es divisible por 3 ni 5 retorna el número + FizzBuzz si el número es divisible por 3 y 5 + Si el número no es divisible por 3 ni 5 retorna el número + Si el número es negativo o > 100 retorna un error * - * DEfinir tests - * 1. Se llama a la funcion para ver que no exista la clase y todo funciona + * Definir tests + * 1. Se llama a la funcion para ver que no exista la clase * 2. Se pasa un número divisible por 3 y retorna Fizz * 3. Se pasa un número divisible por 5 y retorna Buzz - * 4. se pasa un numero divisble por 2 y 5 y retorna FizzBuzzLogic + * 4. se pasa un numero divisble por 3 y 5 y retorna FizzBuzz * 4. Se pasa un número no divisble por 3 y retorna el numero como string - * 5. se pasa nulo y retorna excepción - * 6. se pasa un número negativo y retorna excepción - * - */ \ No newline at end of file + * 5. se pasa un número negativo y retorna excepción + * 6. se pasa un número mayor que 100 retorna una excepción + * + */ \ No newline at end of file diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzz.sln b/TDD/practica2023_2/FizzBuzz/FizzBuzz.sln new file mode 100644 index 0000000..a42d022 --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzz.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FizzBuzzProdCode", "FizzBuzzProdCode\FizzBuzzProdCode.csproj", "{429E1E85-D105-4130-A929-8CFE50A1323C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FizzBuzzTest", "FizzBuzzTest\FizzBuzzTest.csproj", "{1FAFDCE2-618A-4038-93DA-22C6C81764F9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {429E1E85-D105-4130-A929-8CFE50A1323C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {429E1E85-D105-4130-A929-8CFE50A1323C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {429E1E85-D105-4130-A929-8CFE50A1323C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {429E1E85-D105-4130-A929-8CFE50A1323C}.Release|Any CPU.Build.0 = Release|Any CPU + {1FAFDCE2-618A-4038-93DA-22C6C81764F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1FAFDCE2-618A-4038-93DA-22C6C81764F9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1FAFDCE2-618A-4038-93DA-22C6C81764F9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1FAFDCE2-618A-4038-93DA-22C6C81764F9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzLogic.cs b/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzLogic.cs new file mode 100644 index 0000000..42fdb8c --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzLogic.cs @@ -0,0 +1,37 @@ +namespace FizzBuzzProdCode; + +public class FizzBuzz +{ + private const int Fizz = 3; + private const int Buzz = 5; + private const int MaxNumber = 100; + public string Convert(int number) + { + string result = ""; + if (number >= 0 && number <= MaxNumber ) + { + result += IsDivisibleByFizz(number); + result += IsDivisibleByBuzz(number); + if (result == "") + result += number.ToString(); + } + else + { + throw new InvalidDataException(); + } + + return result; + } + + private static string IsDivisibleByBuzz(int num) + { + return (num % Buzz == 0) ? "Buzz" : ""; + } + + private static string IsDivisibleByFizz(int num) + { + return (num % Fizz == 0) ? "Fizz" : ""; + } + + +} \ No newline at end of file diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzProdCode.csproj b/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzProdCode.csproj new file mode 100644 index 0000000..6836c68 --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzzProdCode/FizzBuzzProdCode.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTest.csproj b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTest.csproj new file mode 100644 index 0000000..444d807 --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTest.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTests.cs b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTests.cs new file mode 100644 index 0000000..07c760e --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/FizzBuzzTests.cs @@ -0,0 +1,95 @@ +using FizzBuzzProdCode; +namespace FizzBuzzTest; +/* + * + * Estructura de los test + Arrange + Act + Assert + * + * Reglas FizzBuzzLogic + * Crear una clase que tenga un método que dado un número retorne: + Fizz si el número es divisible por 3 + Buzz si el número es divisible por 5 + FizzBuzz si el número es divisible por 3 y 5 + Si el número no es divisible por 3 ni 5 retorna el número + Si el número es negativo o > 100 retorna un error + * + * Definir tests + * 1. Se llama a la funcion para ver que no exista la clase + * 2. Se pasa un número divisible por 3 y retorna Fizz + * Se pasa un 3 => Fizz + * 3. Se pasa un número divisible por 5 y retorna Buzz + * Se pasa un 5 => Buzz + * 4. se pasa un numero divisble por 3 y 5 y retorna FizzBuzz + * se pasa 15 => FizzBuzz + * 5. Se pasa un número no divisble por 3 y retorna el numero como string + * Se pasa un 6 => Fizz + * Se pasa un 10 => Fizz + * Se pasa un 30 => FizzBuzz + * 6. se pasa un número negativo y retorna excepción + * 7. se pasa un número mayor que 100 retorna una excepción + * + */ + +public class FizzBuzzTests +{ + [Theory] + [InlineData(3)] + [InlineData(6)] + [InlineData(12)] + public void Given_Divisible_By_Three_Returns_Fizz(int param) + { + //arrange + FizzBuzz fb = new FizzBuzz(); + string want = "Fizz"; + //act + string got = fb.Convert(param); + + //assert + Assert.Equal(want, got); + } + + [Theory] + [InlineData(5)] + [InlineData(10)] + public void Given_Divisible_ByFive__Returns_Buzz(int param) + { + FizzBuzz fb = new FizzBuzz(); + string want = "Buzz"; + string got = fb.Convert(param); + Assert.Equal(want, got); + } + + [Fact] + public void Given_Seven_return_Seven() + { + FizzBuzz fb = new FizzBuzz(); + string want = "7"; + string got = fb.Convert(7); + Assert.Equal(want, got); + } + + [Fact] + public void Given_FifthTeen_return_FizzBuzz() + { + FizzBuzz fb = new FizzBuzz(); + string want = "FizzBuzz"; + string got = fb.Convert(15); + Assert.Equal(want, got); + } + + [Fact] + public void Given_Negative_Number_return_Exception() + { + FizzBuzz fb = new FizzBuzz(); + Assert.Throws(() => fb.Convert(-8)); + } + + [Fact] + public void Given_BiggerThan_100_return_Exception() + { + FizzBuzz fb = new FizzBuzz(); + Assert.Throws(() => fb.Convert(101)); + } +} \ No newline at end of file diff --git a/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/Usings.cs b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/TDD/practica2023_2/FizzBuzz/FizzBuzzTest/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/TDD/practica2023_2/casos.rtf b/TDD/practica2023_2/casos.rtf new file mode 100644 index 0000000..f605a7c --- /dev/null +++ b/TDD/practica2023_2/casos.rtf @@ -0,0 +1,40 @@ +{\rtf1\ansi\ansicpg1252\cocoartf2580 +\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fmodern\fcharset0 Courier-Oblique;} +{\colortbl;\red255\green255\blue255;\red116\green187\blue89;\red29\green29\blue29;} +{\*\expandedcolortbl;;\csgenericrgb\c45490\c73333\c34902;\csgenericrgb\c11373\c11373\c11373;} +\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 +\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 + +\f0\i\fs26 \cf2 \cb3 /*\ + *\ + * Estructura de los test\ + Arrange\ + Act\ + Assert\ + *\ + * Reglas FizzBuzzLogic\ + * Crear una clase que tenga un m\'e9todo que dado un n\'famero retorne:\ + Fizz si el n\'famero es divisible por 3\ + Buzz si el n\'famero es divisible por 5\ + FizzBuzz si el n\'famero es divisible por 3 y 5\ + Si el n\'famero no es divisible por 3 ni 5 retorna el n\'famero\ + Si el n\'famero es negativo o > 100 retorna un error\ + *\ + * Definir tests\ + * 1. Se llama a la funcion para ver que no exista la clase \ + * 2. Se pasa un n\'famero divisible por 3 y retorna Fizz\ + * Se pasa un 3 => Fizz\ + * 3. Se pasa un n\'famero divisible por 5 y retorna Buzz\ + * Se pasa un 5 => Buzz \ + * 4. se pasa un numero divisble por 3 y 5 y retorna FizzBuzz\ + * se pasa 15 => FizzBuzz\ + * 5. Se pasa un n\'famero no divisble por 3 y retorna el numero como string\ + * Se pasa un 6 => Fizz\ + * Se pasa un 10 => Fizz\ + * Se pasa un 30 => FizzBuzz\ + * 6. se pasa un n\'famero negativo y retorna excepci\'f3n\ + * 7. se pasa un n\'famero mayor que 100 retorna una excepci\'f3n\ + *\ + */ \ +\ +} \ No newline at end of file