Untitled
unknown
plain_text
2 years ago
1.6 kB
17
Indexable
using System.Collections.Generic;
using System.Linq.Expressions;
using System;
using System.Threading;
using Microsoft.EntityFrameworkCore;
using Moq;
using NUnit.Framework;
using Product_Stock_Maintenance.models;
using ProductStockMaintenance.Repo;
namespace UnitTest
{
[TestFixture]
public class RepoTest
{
private string ConnectionStrings = "Server=localhost;Database=Template;User=root;Password=Psnumber#2023;";
[Test]
[TestCase("pavan", "pavan@123")]
[TestCase("bharadwaj", "bharadwaj@123")]
[TestCase("invalidUser", "invalidPassword")]
public async Task ValidateUserTest(string username, string password)
{
//Arrange
var options = new DbContextOptionsBuilder<TemplateContext>()
.UseMySql(ConnectionStrings, new MySqlServerVersion(new Version(8, 0, 23)))
.Options;
using (var dbContext = new TemplateContext(options))
{
// Act
var repo = new Repo(dbContext);
var result = await repo.ValidateUser(username, password);
// Assert
switch (result)
{
case "admin":
case "users":
case "Invalid login Credentials ":
Assert.Pass();
break;
default:
Assert.Fail();
break;
}
}
}
}
}Editor is loading...
Leave a Comment