You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
API/src/Tests/UnitTestsEntities/DataSourceEntityTests.cs

103 lines
2.8 KiB

namespace UnitTestsEntities;
using Xunit;
using System.Linq;
using Entities;
using Microsoft.EntityFrameworkCore;
public class DataSourceEntityTests
{
[Fact]
public void Add_DataSource_Success()
{
var dataSource = new DataSourceEntity
{
Type = "GPS",
Model = "Garmin Forerunner 945",
Precision = 0.1f
};
/*
using (var context = new StubbedContext(options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "GPS");
Assert.NotNull(savedDataSource);
Assert.Equal("Garmin Forerunner 945", savedDataSource.Model);
}*/
}
[Fact]
public void Update_DataSource_Success()
{
var dataSource = new DataSourceEntity
{
Type = "Heart Rate Monitor",
Model = "Polar H10",
Precision = 0.2f
};
/*
using (var context = new StubbedContext(options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "Heart Rate Monitor");
savedDataSource.Model = "Polar H9";
context.SaveChanges();
}
using (var context = new StubbedContext(options))
{
var updatedDataSource = context.DataSources.First(d => d.Model == "Polar H9");
Assert.NotNull(updatedDataSource);
Assert.Equal("Heart Rate Monitor", updatedDataSource.Type);
Assert.Equal(0.2f, updatedDataSource.Precision);
}*/
}
[Fact]
public void Delete_DataSource_Success()
{
var dataSource = new DataSourceEntity
{
Type = "Smartwatch",
Model = "Apple Watch Series 6",
Precision = 0.05f
};
/*
using (var context = new StubbedContext(options))
{
context.Database.EnsureCreated();
context.DataSources.Add(dataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
{
var savedDataSource = context.DataSources.First(d => d.Type == "Smartwatch");
context.DataSources.Remove(savedDataSource);
context.SaveChanges();
}
using (var context = new StubbedContext(options))
{
var deletedDataSource = context.DataSources.FirstOrDefault(d => d.Type == "Smartwatch");
Assert.Null(deletedDataSource);
}*/
}
}