Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adición de proyecto de pruebas y modificaciones en el código. #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions gestionBancariaApp/gestionBancaria.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,33 @@ public double obtenerSaldo()

public void realizarReintegro(double cantidad)
{

if (cantidad <= 0)
{
mostrarError(ERR_CANTIDAD_INDICADA_NEGATIVA);
throw new ArgumentOutOfRangeException("Cantidad indicada es negativa");
}
else
{
if (cantidad > 0 && saldo > cantidad)
if (cantidad > 0 && saldo >= cantidad)
{
saldo -= cantidad;

}
else
mostrarError(ERR_SALDO_INSUFICIENTE);

throw new ArgumentOutOfRangeException("Saldo insuficiente");
}

}

public void realizarIngreso(double cantidad)
{

if (cantidad < 0)
{
mostrarError(ERR_CANTIDAD_INDICADA_NEGATIVA);
throw new ArgumentOutOfRangeException("Cantidad indicada es negativa");
}
else
{
if (cantidad > 0)
saldo -= cantidad;
}

saldo += cantidad;
}
}


Expand All @@ -80,4 +75,16 @@ public void mostrarError(int error)
}

}

public void aperturaCuenta(double cantidadApertura)
{
if(cantidadApertura >=1 && cantidadApertura <= 100)
{
saldo = cantidadApertura;
}
else
{
saldo = 0;
}
}
}
16 changes: 11 additions & 5 deletions gestionBancariaApp/gestionBancariaApp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gestionBancariaApp", "gestionBancariaApp.csproj", "{A1EDD74E-C398-4F83-AA6E-75E96499221A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gestionBancariaApp", "gestionBancariaApp.csproj", "{825751E1-FDB6-44BF-863D-A747B244477A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gestionBancariaTest", "..\gestionBancariaTest\gestionBancariaTest.csproj", "{920157BA-B9CC-4F21-9FD0-F7844318F7A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A1EDD74E-C398-4F83-AA6E-75E96499221A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1EDD74E-C398-4F83-AA6E-75E96499221A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1EDD74E-C398-4F83-AA6E-75E96499221A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A1EDD74E-C398-4F83-AA6E-75E96499221A}.Release|Any CPU.Build.0 = Release|Any CPU
{825751E1-FDB6-44BF-863D-A747B244477A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{825751E1-FDB6-44BF-863D-A747B244477A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{825751E1-FDB6-44BF-863D-A747B244477A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{825751E1-FDB6-44BF-863D-A747B244477A}.Release|Any CPU.Build.0 = Release|Any CPU
{920157BA-B9CC-4F21-9FD0-F7844318F7A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{920157BA-B9CC-4F21-9FD0-F7844318F7A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{920157BA-B9CC-4F21-9FD0-F7844318F7A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{920157BA-B9CC-4F21-9FD0-F7844318F7A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
20 changes: 20 additions & 0 deletions gestionBancariaApp/gestionBancariaTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("gestionBancariaTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("gestionBancariaTest")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("530c1eab-7abe-4d87-8741-88b7d0cb6e50")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
30 changes: 30 additions & 0 deletions gestionBancariaApp/gestionBancariaTest/gestionBancariaTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using gestionBancariaApp;

namespace gestionBancariaTest
{
[TestClass]
public class gestionBancariaTest
{
[TestMethod]
public void validarMetodoIngreso()
{
// Preparación del caso de prueba
double saldoInicial = 1000;
double ingreso = 500;
double saldoActual = 0;
double saldoEsperado = 1500;

// Instancia de objeto de la clase gestionBancaria
gestionBancaria cuenta = new gestionBancaria();

// Método a probar
cuenta.realizarIngreso();

// Afirmación de la prueba (resultado esperado vs. resultado obtenido)
saldoActual = cuenta.obtenerSaldo();
Assert.AreEqual(saldoEsperado, saldoActual, 0.001, "El saldo de la cuenta no es correcto.");
}
}
}
68 changes: 68 additions & 0 deletions gestionBancariaApp/gestionBancariaTest/gestionBancariaTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{530C1EAB-7ABE-4D87-8741-88B7D0CB6E50}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>gestionBancariaTest</RootNamespace>
<AssemblyName>gestionBancariaTest</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.7\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.7\build\net45\MSTest.TestAdapter.targets')" />
</Project>
5 changes: 5 additions & 0 deletions gestionBancariaApp/gestionBancariaTest/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.2.7" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.2.7" targetFramework="net472" />
</packages>
20 changes: 20 additions & 0 deletions gestionBancariaTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("gestionBancariaTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("gestionBancariaTest")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("920157ba-b9cc-4f21-9fd0-f7844318f7a4")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Loading