Skip to content

Commit

Permalink
unit test finished
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonymakarewicz committed Jul 30, 2024
1 parent 96181b8 commit df82e15
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/unit/market_data/test_market_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,29 @@ using namespace OptionPricer;
// Test fixture for MarketData tests
class MarketDataTest : public ::testing::Test {
protected:
MarketDataTest() : observer(nullptr) {}

static void SetUpTestSuite() {
marketData = MarketData::getInstance();
marketData->addStock("AAPL", 150.0, 0.2, 0.01);
}

void SetUp() override {
observer = std::make_shared<Mocks::Option>("AAPL");
marketData->addObserver(observer);
}

static void TearDownTestSuite() {
// Reset the state if necessary
marketData.reset();
void TearDown() override {
observer.reset();
//MarketData::instance_ = nullptr; // Assuming this is allowed in your implementation to reset the singleton
marketData->removeObserver();
}

static std::shared_ptr<MarketData> marketData;
static std::shared_ptr<Mocks::Option> observer;
//std::string ticker;
std::shared_ptr<Mocks::Option> observer;
};

// Static member initialization to avoid undefined behaviour
std::shared_ptr<MarketData> MarketDataTest::marketData = nullptr;
std::shared_ptr<Mocks::Option> MarketDataTest::observer = nullptr;

TEST_F(MarketDataTest, SingletonInstance) {
auto instance1 = MarketData::getInstance();
Expand Down

0 comments on commit df82e15

Please sign in to comment.